Including resources folder in apk - android

I'm writing a hybrid application in Cordova using Intel XDK. I've found and installed plugin for displaying native notifications on device, but got stuck with problem concerning icons customization. I am supposed to use Local resource for native resources relative to the res/drawable/ (Android) or Resources/ (iOS) folder.
And here comes the problem, because I can not make Intel XDK to add anything into the res folder inside .apk. I've found out that I should create appropriate folder structure (platforms/android/res/drawable) and place there my icon, but unfortunately one is not loaded in the .apk. How to build application so my own resources would be included? Am I missing some xml config or settings?
Plugin Link

Despite the statements in the forum post, it may be possible to do what you are asking about, but not without some effort. The forum post is correct, there is no way to add custom images, for use by the plugin you are trying to use, in your XDK project as described by the plugin docs. In the case of an XDK project, the platform directories pointed to by those plugin docs exist only in the build system, where it uses Cordova CLI to build your app, they do not exist in your local XDK project directory (despite the resemblance to a Cordova CLI project, your local project directory is missing the platform folders).
To do this you'd have to create a simple plugin, that will add those resources into the respective platform folder locations at build time. I'd have to spend some time figuring out precisely how to do this, which I don't have time for right now, but at least wanted to help you give it a try, if you are up for it. :-)
The simplest way to figure this out would be to inspect a plugin that adds custom graphic images to the built app it is being included in. The inAppBrowser is one you could use as a guide, certainly there are others. Inspect the plugin.xml file for that pluginand find the Android platform section where it copies files from the plugin's src directory into the platform's res directory. In essence, what you want to do is create a small custom plugin that contains a plugin.xml file that includes such directives, plus the custom images you want to copy into the respective locations for each platform. So you'd also have an src/android/res/etc... directory containing your Android images, and so on for the other platforms. You may have to look at a few plugins to see how this is done for other platforms.
Here's the plugin guide, most of which you won't need, just the bits to create a basic plugin.xml file and the local images you want to add to your app > https://cordova.apache.org/docs/en/5.1.1/guide/hybrid/plugins/index.html
You'll then have to add this plugin as a "local" plugin to your project, using the Plugin Manager tool. Do not develop your plugin inside the <project>/plugins directory, that is a destination. Develop it somewhere else, either inside your project (e.g., <project>/my-custom-icons) or somewhere outside the project. The Plugin Manager doesn't care where it is located, as long as it is somewhere on your local dev system and NOT inside the <project>/plugins directory.

I have posted a solution for this problem in this thread:
res/drawable files in Intel XDK
Altough I have not yet tested this on iOS, the solution should be similar.

Related

Build a phonegap app with phonegap build

I want to convert my app into a hybrid app using phonegap build.
How do I do that?
I see different setups in basically every tutorial.
In this one, there is not a single platform folder, just the usual img/css folders, plus the config.xml
In many other tutorials I see a folder structure like www, platforms, etc. with the andorid and ios platform code.
How do I setup my phonegap project??? Do I need the platform, do I not need the platform, do I need the cordova.js, do I not need it??
It seems information about this is somewhat contradictory and often outdated.
E. g. I created my app using these steps.
Which does create all those folders like www and platform, however, the app doesnt install correctly after I built it with phonegap build. So something must be configured wrongly... I mean, it's there OWN site and it fails!
What is the correct folder structure that I need to convert my app into a hybrid app that will run on iOS, android and windows phone, using phonegap build?
It depends on whether you plan to use PhoneGap to develop or only to compile (Phonegap Build).
I will show how I used until a little time ago.
I used to develop an Ionic project and made all the development with it. When I needed to test something on the phone, I was using the Phonegap Build.
Both projects have the folder "www". To use Phonegap Build site, I was replacing the folder "www" of Phonegap project with the "www" folder of Ionic project. Then just send the Phonegap project ZIP to Phonegap Build site. This always worked for me.
After creating the project (phonegap create my-app), basically you do the project at "www" folder and configures preferences in config.xml (fullscreen, plashScreen, android-minSdkVersion, etc).
If you use Phonegap Build site you donĀ“t need to add platforms (platform phonegap add) and not need to run "phonegap run android"
PhoneGap Build's only requirement for your application structure is that the config.xml and index.html is in the top level of your application.
Make test:
- phonegap create my-app
- configure config.xml (If necessary, not required)
- config.xml and index.html in the same folder (preferably in www)
- ZIP
- Upload ZIP on Phonegap Build

How to determine what version of Cordova was used to build a legacy app?

We have a legacy app built by an external company that was developed using the Cordova framework for creating mobile apps.
I am having some issues making changes and decided try to re-build it using the exact same version of Cordova that the original developers had used but unsure how to find this info out (the company no longer operate)
Is there way in to find this out by looking at a particular file or folder within my app?
As far as I know, you should look for "FrameworkVersion" at ".abproject" in the root of your project.
If that doesn't work -
Here is another solution - find the newest file in "your_app.apk" ( as you know apk is renamed zip files, so it content can be easily viewed with rar or zip ).
After that go to http://archive.apache.org/dist/cordova/ - and look for the newest cordova-x.x.x-src.zip, which was created before the newest file in your apk. In the most cases that's is what you looking for.

How tell plugman that I want to update a file that may not be present?

I wrote an android phonegap 3 plugin that starts an activity (the activity is part of plugin) and uses a native android UI.
Now I want to follow the plugin specification to be able to install the plugin using the CLI.
My plugin has resources in the xml files /res/values/attrs.xml, /res/values/colors.xml and /res/values/ids.xml
My issue is that those files are not created by the platform add android command, so I can't use <config-file> to patch them.
I don't want to use <source-file> because I would like to avoid conflicts if I have to install other plugins also using those files.
Is there a proper way to update a file if it exists or create it if it doesn't?

How to use platform-specific plugins in Cordova app dev workflow?

I'm new to developing apps with Cordova but I've got a lot working well. I just successfully implemented the 'phonegap-facebook-plugin'.
However, following the instructions, I put many files (from the facebook SDK and plugin) directly into the /platform/ios/ directory - which means instead of working in the root /www/ directory and building both platforms at once, my code is now less 'flexible' and is platform specific.
Is there a better way to do structure my files and/or workflow? Am I missing a step or a trick?
I appreciate any help.
Starting with Cordova 3.x, there is a new cordova command-line interface that will greatly help you organize code for multiple operating systems. You will use the CLI to create a project and then do all of your development in the main /www/ folder. You can then use the CLI to run commands that will copy your /www/ code into the appropriate place for web assets for each platform (like /myApp/assets/www/ for Android.)
Check out my answer here: Should a phonegap plugin be declared in the config.xml file?
I talk about how the directory structure that gets created, how you should version control /www/ and /merges/ folders, and how you can think about anything in /platforms/ as a build artifact. (The things in this folder aren't necessarily build artifacts but it's helpful to think about it that way if you are doing cross-platform work.)
If you are only developing for a single platform, or are hacking on the native pieces of the platform, then you will be inside these folders changing things. I don't recommend this approach for most people though because the vast majority of use cases are creating cross-platform apps with HTML5.
I have been working on the documentation to make this more clear. The new overview guide should help you: https://github.com/mbillau/cordova-docs/blob/30fb71d11b4db5d34b3ff1c48a16443d5fed1be3/docs/en/edge/guide/overview/index.md (If you read it and still have questions, please let me know so I can address those questions in the documentation and everyone will benefit.)
EDIT: I did not see that most of your question was about plugins. What should happen is that if you have a plugin updated for Cordova 3.x, then you should be able to install it with cordova plugin add .... This should copy the native and .js files into the /plugins/ folder for you. Then when you do cordova prepare it will copy the specific platform files for that plugin into the specific platform folder. So you shouldn't have to copy files all over the place. I'm pretty sure that the plugin you are using is not supported with 3.x though, in which case...I'm not really sure what to tell you. Running prepare should just copy over files, not erase files already there...but I'm not positive.

How do I handle and properly version-control a Phonegap iOS/Android project?

I have been investigating Phonegap as a method of deploying an app to both Android and iOS. However, it seems like depending on what device you are programming for, there is a different set of instructions.
How do I set up something where the 'project' for both Xcode and ant are in separate directories but they both point to the same set of common assets? And how do I version control this...what should I .hgignore and what is necessary to keep around?
We generally have a www folder with the html, js, css etc for your app and a folder next to it that contains the xcode project and android project then write a simple script to copy the www code into the platform specific projects ... some of this is made more simple with tools like github.com/brianleroux/cordova
You could also check out build.phonegap.com

Categories

Resources