user2527089
user2527089

Reputation: 11

Phonegap How to make android build

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

Upvotes: 1

Views: 4110

Answers (2)

miwe
miwe

Reputation: 563

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)

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

  2. Add the 'android sdk tools' and 'android sdk platform-tools' to your path.

  3. In your cordova app (e.g. /myApp) folder, execute $cordova platform add android

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

  5. Plug in your Android Device or create and start a new AVD (In Eclipse: Window -> 'Android Virtual device manager').

  6. execute $cordova prepare android

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

  8. In Eclipse: Run -> Run Configurations -> Target:: Enter Your settings depending on wether you use AVD or not.

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

Upvotes: 5

wnc_21
wnc_21

Reputation: 1771

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.

Upvotes: 0

Related Questions