Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

cordova - Phonegap Build android - error "Adding the android platform" ENOENT

Helo, I am currently trying to build the base phonegapp android app that's automatically created, so I navigated to the directory... but when I use the command

phonegap build android

I just get this random error, as shown in the attatched picture. enter image description here

Extra info

I am currently on Windows 8, and am completely new to making apps, and am new to the command line as well. Not very familiar with this stuff...

What I'm trying to do would be called 'compiling', right?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yeah, I had the same problem yesterday - but with a little help of a colleague I got it!

Step by step tutorial (for Windows)

  1. Install node js
  2. Install phonegap using command line: npm install -g phonegap
  3. Install Android SDK
  4. Launch Android SDK Manager and install Android 4.4.2 (API19)
    • Because latest phonegap/cordova version requires this
    • Documentation for Android SDK and SDK Platform should be enough
    • Also update already existing packages
  5. Create an environment variable called ANDROID_HOME which points to destination of Android SDK. e.g. C:UsersYouAppDataLocalAndroidandroid-sdk
  6. Download Apache Ant and extract the archive somewhere
  7. Create an environment variable called ANT_HOME which points to destination where you have extracted Ant
  8. Install JDK (Java Development Kit) for your System. Before you are able to download, you have to accept the licence
  9. Create an environment variable called JAVA_HOME which points to destination of JDK
  10. If you want to add plugins via phonegap automatically you should also install GIT.
  11. Last but not least you need to add the following directories to PATH environment variable:
    • %ANT_HOME%in;%ANDROID_HOME%ools;%ANDROID_HOME%platform-tools;%JAVA_HOME%in
    • Each folder is separated by a semicolon

Setting environment variables will take effect just for new command line windows. So you should reopen it, after the whole process.

Easy, isn't it? ;-)

Now you can use phonegap build android after you've created a new phonegap project. If you have your smartphone plugged via USB and installed the USB drivers, and activated the USB Debugging on smartphone, you may use

phonegap run android

And the ready build APK will be transfered and executed on your smartphone. Perfect for testing.

If you want to create a final release APK, go to YOURPROJECTplatformsandroidant-build and enter ant release. You'll find the final APKs in YOURPROJECTplatformsandroidin.

They are unsigned, here is a Noob guide to signing an APK.

I have tested a Barcode Scanner example, and it works seamlessly.

Have fun!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...