Developing with Eclipse and Phonegap/Cordova 3

后端 未结 3 789
生来不讨喜
生来不讨喜 2020-12-23 17:02

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 phone

3条回答
  •  有刺的猬
    2020-12-23 17:57

    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:

    1. 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.

    2. 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.

    3. 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.

    4. 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.

    5. 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)

提交回复
热议问题