Developing with Eclipse and Phonegap/Cordova 3

后端 未结 3 792
生来不讨喜
生来不讨喜 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:37

    See my answer here: Multiple Html files in PhoneGap Android project

    Why I moved to Netbeans with Phonegap 3.0 CLI. Suited my workflow better.

    0 讨论(0)
  • 2020-12-23 17:50

    in addition to the solution above, i created an 'external tools' configuration that runs the phonegap utility with 'local build android' options and a environment PATH variable set to '/opt/local/bin:/usr/bin:/bin' for my Mac. from there, i installed the Eclipse CDT tools and used its 'Launch Group' feature to run the external tool from the top-level project before calling a debug on the platform-specific project.

    seems to work fairly well. unfortunately they top-level project doesn't 'remember' the Launch Group execution, so i have to select it from the Debug drop-down each time. i converted the top-level project to a JavaScript as a test, but it didn't seem to help and the 'Run/Debug Settings' in Project Properties are all greyed out.

    0 讨论(0)
  • 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)

    0 讨论(0)
提交回复
热议问题