It seem the documentation is a bit thin and I assure you I have tried to find this online, but I really don't get how the development process is supposed to work with phonegap and eclipse.
I followed one of the many tutorials and created the Hello World example using the the cordova command line. I then added the android platform and ran the build. After that, I added the andoridy bit as a project in eclipse with respect to existing source as instructed using the subdirectory platforms/android directory. This allowed me to set up the emulator and all worked very well.
The problem I now have is with the development process.
I understand that I have to edit the top level files, not the ones presented in the assets directory of the project in eclipse as these are created using the "build" command. These top level files don't exist in the project I've created in eclipse as they are above the root of the project.
So, my question is ... can I use eclipse to develop this project in a sensible way?
What I'm doing at the moment is editing the android www files and then to pump it up to the cloud build, I'm copying them back up the tree. This seems insane.
Is there a way of having the real files available in eclipse so I can develop them and then build and deploy to an emulator easily?
PS is it my imagination or does cordova build take ages!
Solution
I added a folder within the Android project which is a link to the location of the www in the root. This is under advanced options of creating a folder.
To do this, you must use two different eclipse projects. One containing the myProject/www folder for developing (let's call it 'top-level project') and one for your specific platform-project (e.g. android, as you already did).
In your top level project, you write your code and, if you feel like, you can even debug up to a certain degree (functions which do not require cordova). Then save and type cordova prepare
in your CLI. You can then switch to your android project, hit refresh (F5) and run the emulator / device and look for bugs, and make Android-Manifest changes. If you want to change code, switch again to your top-level project and do the same over again.
This seems a bit unhandy, right. Nevertheless, think about cordova not beeing only for developing on android, but also on ios, windows phone, blackberry, ... To access all these platforms, you have to switch to multiple ide's anyway. It makes it a lot easier then, to have the top-level code in a independent project.
Some sidenodes:
After doing this process a few times, you will loose not more than 2 or 3 seconds to cordova prepare
and switch projects. Which is ok, I think.
I myself don't just use different eclipse projects, I even use different eclipse installations. This seemed better arranged for me, as it protects me from confusing top and low level files.
Even if you develop only for android, you should use two different projects, as 'cordova prepare' (or any cli command containing prepare, as build, emulate and run) would overwrite/delete your files.
On my installation, building with CLI takes the same amount of time as it does in eclipse. Which makes sense, as I am using the same sdk for both. However, in the process written above, there is no need to use the cli-build command.
If you use just the android platform and don't get easily confused with same-named files in one project, you might link the myApp/www folder in your Android project. In this case, you will only have one project (Credit for this answer goes to stevemarvell himself, im just adding this here for completeness)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With