Problems with using Phonegap

Asked

Viewed 1,046 times

3

I’m trying to use Phonegap for the first time, but I’m having problems.

I already had Nodejs installed, I was able to install Phonegap with npm install phonegap without problems. Then, as you suggest this page, I created an app with phonegap create myapp without problems, but when trying to run with phonegap run androidI got the following error:

C:\Users\MEU_USUÁRIO\Desktop\myapp>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...

C:\Users\MEU_USUÁRIO\.cordova\lib\android\cordova\3.5.1\bin\node_modules\q\q.js:126
                    throw e;
                          ^ Error: ERROR : executing command 'ant', make sure you have ant installed and add ed to your path.
    at C:\Users\MEU_USUÁRIO\.cordova\lib\android\cordova\3.5.1\bin\lib\check_reqs.js: 47:27
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:465:12) { [Error: C:\Users\MEU_USUÁRIO\.cordova\lib\android\cordova\3.5.1\bin\create.bat: Com mand failed with exit code 8] code: 8 }    [error] C:\Users\MEU_USUÁRIO\.cordova\lib\android\cordova\3.5.1\bin\create.bat: Co mmand failed with exit code 8

Searching on the web, there are several different solutions, apparently each solution works for a different case. I tried npm install cordova, configured JAVA_HOME, ANDROID_HOME, Path, installed this guy from Ant and configured ANT_HOME and nothing said served me, I continue with the same mistake.

The solution presented in this other question didn’t fit me. I don’t know what else to do.

Remember that Androidsdk + Eclipse was already installed and worked before I even installed Phonegap. I am using Windows 7.

  • This error is in relation to Ant_home which should actually be called ANT_DIR and also add it to the windows PATH. To be sure, run the command ant in cmd and see if it runs

  • @Caputo Execute ant in cmd returns Buildfile: build.xml does not exist!\nBuild failed

  • And replaced ANT_HOME by ANT_DIR?

  • @Caputo Now I switched, the error has changed. Now he says that the "newer" version of the SDK, the 19, is not installed. I checked here and I have version 20. I’ll try to install the 19.

  • If I don’t miss the memory, every version of the SDK that will be used needs to be installed separately, but you can set the SDK version in your phonegap APP’s JSON file or in the android manifest

  • 1

    @Caputo Brigadão! Now it’s working right =)

Show 1 more comment

2 answers

2

I managed to solve the problem with two steps:

  • Changing ANT_PATH for ANT_DIR as suggested by our friend @Caputo.

  • Installing version 19 of the SDK (before I only had the 20).

Thanks to @Caputo for the strength!

0

To solve the second error, the correct is not simply install version 19, it works, yes, but if you want to use an older or newer version of the SDK just put the following lines in the config.xml file, in my case configured for android 2.3 (SDK 10).

<preference name="android-minSdkVersion" value="10" />
<preference name="android-targetSdkVersion" value="10" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.