I've got a Phonegap/Cordova 3.0 app that I am testing on Android.
Since version 2.x, Cordova relies heavily on the command-line terminal. I've done all the setup stuff and I can build the app. But two things are troubling me.
First of all, an Android project has two www folders. One is [myproject]/www. The other is [myproject]/platforms/android/assets/www. I'm not sure which of these folders to edit when I am fixing bugs.
If I am correct, the first one is where you place your app files before using the command-line "cordova build" to create the app. The second one should then be only a copy that's used after building, before deploying.
Now my question is, when I make a change to my app and I want to test on device, do I have to use the command line to (re)build the app every time?
[myproject]/www is the directory in which you should put your source files. When you build your app these files are copied in to [myproject]/platforms/[platform]/assets/www. In addition to this, files in [myproject]/platforms/[platform] are also copied to [myproject]/platforms/[platform]/assets/www, which allows you to create per-platform overrides to your files.
Note that you should never edit files in [myproject]/platforms/[platform]/assets/www directly, as they will be deleted next time you build your project.
To run your project on your device use cordova run [platform], or to run it on an emulator use cordova emulate [platform].
I found a solution: in command-line terminal, type cordova run android and the app will be built, deployed and run on device.
Hi First thing : Edit www folder inside the asset folder.
Second : no need of command line build , you can take build via eclipse its very easy, Right click on project root folder --> Run As -> Android Application
Related
I'm building an android app with Visual Studio 15 Community, Ionic and Apache Cordova and I would like to update the icon of my ionic app. I'm emulating the app with Genymotion but I get the same result using the build-in android emulator from VS15.
Additionally, I used a blank ionic project.
I've already tried
I added the source of my icon in the config file (please note that I added the density myself, it has not been generated)
<icon src="resources/android/icon/icon.png" density="xxxhdpi" />
Created the app logo based on this blueprint:
http://ionicframework.com/docs/cli/icon-splashscreen.html
Placed the .png file in the specific folder
I followed the instructions from the ionic and visual studio website
with no results.
I didn't try
Actually, I didn't try to execute the command to update my ressources using $ ionic resources --icon because I think that as soon as I build the app (pressing the play button in VS15) it does all the work for me
Maybe I'm getting something wrong here because usually this isn't a big deal.
I really appreciate all your answers, thank you for taking the time to deal with this!
As of the latest updates. if the splash and the icon did not update. that is because the latest version of ionic creates 2 md5 files of the icon and the splash. which i guess is locking the updates.
just delete these 2 files: “icon.png.md5” and “splash.png.md5”.
then run the following command : ionic cordova resources
then splash and the icon should be updated.
might be helpful to someone out there cheers!!
Density is set to "xxxhdpi" density. Maybe you need to add another screen options?
Try to refresh project, too.
As mentioned earlier by a user whos post has been deleted (why?), all I had to do was to
open my command line
go to the directory in which my project is
type the command $ ionic resources
That's it! Ionic does all the rest
A quick note: I didn't know that I had to install the tools (Android SDK, Apache Cordova etc.) because I thought that Visual Studio downloads them due to the first build so why installing it locally. You must install them locally, it will not work without the tools installed on your machine.
Hope I could help
I have some problem with building an app with cordova. This is my first experience with that software.
I have an existing Android HTML/JS app. I want to do some changes to it, re-build and test it in emulator.
App's files are located in platforms/android/asset/www, I can see them, edit them etc.
Now, after doing the changes, I do a "cordova emulate". I see it builds my app, the emulator starts and… it shows me a Hello World app.
All app's files from asset/www disappeared, and are replaced with "blank", hello world files , like I would just create a new app.
Why is this happening? How to prevent it?
My current cordova version is 4.3.0. The application was probably made and last edited on some older version (few months ago).
Found a similar problem here link but there's no solution there.
Instead of working on the platforms/android/asset/www you have to work on the root www folder, when you run the app the files will be copied to platforms/android/asset/www
I started with cordova and I have some small problems.
I've created an android application. I have installed java, android SDK , Apache Ant and Apache Ant.
I have added android with cordova add platforms android and builded correctly.
1 - When I use cordova run android I get the following error:
an error occured while running the android project . Buildfile : ...Demo \ platforms \ android \ build.xml . ERROR : Failed to install apk to device
I think this is due to the fact that my application is not in debug mode. How to set the debug mode? (' cordova emulate android ' works and launches the emulator )
2 - When I want to load a project in eclipse . (New project - > Android Project from Existing Code) I have the error:
Invalid project description Reason : . Invalid project description
How to overcome this error ?
3 - I want to install external plugins, eg
- https://github.com/ClickInnovate/CordovaPhoneGapPlugins/tree/master/Android/SocialMessage
- https://github.com/phonegap/phonegap-plugins/tree/master/Android/StatusBarNotification
It is said that to copy the java files in the src folder , but, I copy the java files in the original project or one that is build ( in plateform directorie )
If you run cordova run android -d, you will see additional debugging information printed to the console which should hopefully help you narrow down the problem. I've never seen that error you are getting, but to set your device up for debugging you should follow these steps. Some steps may be different or unneeded based on your Android device and version:
Settings --> Click on "About Tablet" --> Click on Build Number 7 times to activate "Developer mode"
Settings --> Developer options --> USB Debugging (make sure it is checked)
Settings -->Security-->Unknown Sources` (make sure it is checked)
Storage --> Click the drop down on the top right --> USB computer connection --> Make sure "Camera (PTP)" is checked
Please ensure that you are following the Android platform guide. If you are getting "Invalid project description" you might just need to type in a project description in one of the boxes in Eclipse? Another thing, make sure you are doing Import-->Android-->Android Project from Existing Code. Finally, it sounds like this might be a goofy Eclipse environment issue, here is another question on SO about this problem.
The plugins that you listed are old, they were made before Cordova 3.X came out. In 3.X, a new plugin management system using Cordova CLI and Plugman is used to install plugins - the only problem is that the plugins need to be updated to use this new format. You could look around to see if somebody has updated those plugins (look on the Fork page on GitHub is one good way.) Otherwise if you can't find an updated plugin, you could try to update the plugin yourself following the upgrade guides on the doc website. To answer your question, the java files would be need to eventually be copied into the build folder. In 3.X, the files are stored in the /plugins/ folder, then copied to the /platforms/android/ folder when you run cordova prepare, and are built into the cordova.jar when you do cordova compile. You can also read about how to install plugins with just plugman.
I have created a build in ios successfully. Now i am trying to make build in android.
I have added android platform and imported this in eclise(ADT). I want to make configuration for android, as i am new to mobile application. I am unable to find any good reference for building android tutorial. I looked into getting started tutorial of phonegap but it was not much helpful
I assume you're using Cordova 3.0 and CLI
Proceed as following (some steps you might have already done, for completeness, I list them here anyway)
Open Eclipse ADT -> Window -> Android SDK Manager and make sure you have at least the 'Android SDK Tools', 'Android SDK Platform-tools' and at least on API installed.
Add the 'android sdk tools' and 'android sdk platform-tools' to your path.
In your cordova app (e.g. /myApp) folder, execute $cordova platform add android
Im assuming you have all your jscode correctly bundled in the /myApp/www folder, as you already have a working ios build. Otherwise, do so.
Plug in your Android Device or create and start a new AVD (In Eclipse: Window -> 'Android Virtual device manager').
execute $cordova prepare android
Open Eclipse and then File -> Import -> Android/Existing Code Into Workspace. In the opening 'Import Projects'-Window, select your /myApp/platforms/android as root directory. Depending on your workspace, you must select 'Copy projects into workspace', however your workspace would better already include the project, as this saves you from importing a new project after every $cordova prepare statement
In Eclipse: Run -> Run Configurations -> Target:: Enter Your settings depending on wether you use AVD or not.
On the bottom right: Run. Your app will be built and run.
Notes:
If you use mulitple platforms (e.g. android and ios), this way is more preferable than the way of user1306579, where you copy/hardlink your code directly in the /myApp/platforms/android/ folder, as you would have to do this for every platfrom equally and even worse: If you run $cordova prepare (or any command containg this, as $cordova run, $cordova build, ...) you would loose your changes.
Never edit JavaScript-Code directly in your /myApp/platforms/(anyplatform)/www/ folder. Always use /myApp/www/ and run $cordova prepare afterwards...
After step 5 you could use $cordova emulate android (for your avd) or cordova run android (real device), which would replace all other steps. However, if there are errors coming up, finding the reasons might be more difficult.
If your questions was over how to configurate the android app (platform merges, manifest configurations, ...) feel free to ask again :)
Regards, miweiss
I builded phonegap application with ant.
I think that this is not a big deal to build it with eclipse. You should copy web resources to the platforms/android/assets/www folder. Then you should use platforms/android as your project folder. I think you can use symbolic or hard links instead of copying to always refer to actual data.
How do I create Android app builds similar to Windows code builds? I have my Android app code base checked in to Tortoise SVN. But I also have the binaries checked in - i.e the apk file etc. and not just the source code. Everytime there is a change I am building it manually on Eclipse and then updating the apk and the code folders. Is there no mechanism to create builds like on Windows where you run a batch file running the visual studio exe to create builds and binaries. I need this because otherwise it s just replacing the apk's everytime. Its very frustrating that I dont know this simple detail so please help!
You can use ant building scripts (details at http://developer.android.com/guide/developing/building/building-cmdline.html).
Actually you have to just checkin your project to SVN. The other team member or even you when loading it in another working space (another PC or diff Eclipse WorkSpace), Eclipse will throw error.
Simply clean the project it should rebuild the app and APK files for you again. Nothing much to worry. Me and my friends have done it several times.
Correct me if I'm wrong.