Search code examples
androidcordovaphonegap-buildhybrid-mobile-app

Not able to add platform to phonegap


I am starting with phonegap I have been following phonegap documentation for basic learning but i am not able to add android platform to my project.

I tried several command cordova platform add android

phonegap platform add android
phonegap build android 

but nothing seems to work

These commands give me following error

    C:\Users\Gaurav\android-phonegap\HelloWorld>cordova platform add android
Creating android project...
Error: C:\Users\Gaurav\.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\create.bat: Command failed with exit code ENOENT
    at ChildProcess.whenDone (C:\Users\Gaurav\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
    at ChildProcess.emit (events.js:95:17)
    at Process.ChildProcess._handle.onexit (child_process.js:818:12)

I have read few solution where they said i need to set android-sdk path. I tried to set SDK Path and platform-tools path also but nothing worked. Any help will be appreciated. I am running on Windows machine.

Thanks in advance.


Solution

  • Try this

    copy tools.jar from JDK lib directory to JRE lib directory. Restart the system

    Then use

    cordova -d platform add android
    

    Answer was found here