Error executing the cordova build command

6

I'm running the command build cordova (after finishing the settings exemplified at this link: PhoneGap The Command-Line Interface ).

But Node.js returns this error:

  

Generating config.xml from defaults for platform "android"
  Preparing android project
  Compiling app on platform "android" via command "cmd" / c
  C: \ Net \ Phonegap \ hello \ platforms \ android \ cordova \ build
  Error: An error occurred while building the android project.Error executing "ant" debug -f "C: \ Net \ Phonegap \ hello \ platforms \ android \ build.xml" ":
  BUILD FAILED
  C: \ Net \ templates \ Phonegap \ android-sdk \ tools \ ant \ build.xml: 601: The following error occurred while executing this line:
  C: \ Net \ templates \ Phonegap \ android-sdk \ tools \ ant \ build.xml: 720: The following error occurred while executing this line:
  C: \ Net \ templates \ Phonegap \ android-sdk \ tools \ ant \ build.xml: 734: Unable to find a javac compiler;   com.sun.tools.javac.Main is not on the classpath.
  Perhaps JAVA_HOME does not point to the JDK.
  It is currently set to "C: \ Program Files \ Java \ jre7"

     

Total time: 2 seconds

     
    

at ChildProcess. (C: \ Users \ myuserpc \ AppData \ Roaming \ npm \ node_modules \ cordova \ src \ compile.js: 65: 22)
    at ChildProcess.EventEmitter.emit (events.js: 98: 17)
    at maybeClose (child_process.js: 743: 16)
    at Socket. (child_process.js: 956: 11)
    at Socket.EventEmitter.emit (events.js: 95: 17)
    at Pipe.close (net.js: 466: 12)

  

My config.xml

<widget id="com.example.hello" version="0.0.1">
  <name>HelloWorld</name>
  <description>
     A sample Apache Cordova application that responds to the deviceready event.
  </description>
  <author email="[email protected]" href="http://phonegap.com">
     Apache Cordova Team
  </author>
  <content src="index.html" />
  <access origin="*" />
  <preference name="Fullscreen" value="true" />
  <preference name="WebViewBounce" value="true" />
  <feature name="Device">
    <param name="android-package" value="org.apache.cordova.device.Device" />
  </feature>
</widget>

And my AndroidManifest.xml

<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" android:windowSoftInputMode="adjustPan" package="com.example.hello" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:configChanges="orientation|keyboardHidden|keyboard|locale" android:label="@string/app_name" android:name="HelloWorld" android:theme="@android:style/Theme.Black.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
</manifest>

My question is, what is missing so that the cordova build command works correctly?

My Path is set up right. I added the JAVA_HOME variable with the correct path.

    
asked by anonymous 19.02.2014 / 15:34

2 answers

2
  

C: \ Net \ templates \ Phonegap \ android-sdk \ tools \ ant \ build.xml: 734 Unable to find a javac compiler;   com.sun.tools.javac.Main is not on the classpath.

     

Perhaps JAVA_HOME does not point to the JDK.   It is currently set to "C: \ Program Files \ Java \ jre7"

If I remember correctly, in fact there is no Java compiler in the JRE folder. I think your problem is the same: either you assigned JAVA_HOME to the wrong folder or you do not have a Java compiler installed in your environment (ie you need Java SDK / JDK, not JRE).

If you have a folder type "C:\Program Files\Java\jdk7" or something, that's where your JAVA_HOME should point.

    
19.02.2014 / 15:48
1

To build on the android platform you need to install JDK, Apache Ant and Android SDK. You also need to configure the following environment variables in the OS: JAVA_HOME, ANDROID_HOME, and ANT_HOME.

    
19.02.2014 / 16:09