5

I have been trying for 2 days to sort out this problem I am having with phonegap/cordova.

Working on a mac, I can build for iOS. But everytime I try to build for android, I get this error:

BUILD FAILED
/Users/m/Documents/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:601: The following error occurred while executing this line:
/Users/m/Documents/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Users/m/Documents/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:734: Class not found: javac1.8

Any help would be great!! No online resources has helped!

  • 1
    please check this [http://stackoverflow.com/questions/22520093/trying-to-build-android-emulator-with-ionic-fails-class-not-found-javac1-8?rq=1][1] [1]: http://stackoverflow.com/questions/22520093/trying-to-build-android-emulator-with-ionic-fails-class-not-found-javac1-8?rq=1 – raghu Jun 30 '14 at 07:35
  • 1
    Possible duplicate of [Eclipse and Ant: javac1.8 class not found](http://stackoverflow.com/questions/20702626/eclipse-and-ant-javac1-8-class-not-found). It appears Ant is not compatible with Java 8. You will need to use Java 7. – jww Aug 15 '14 at 04:08
  • 1
    Yes, I had to delete it all and reinstall java 1.6 for anyone else stuck... – SirJoeyMichaels Aug 15 '14 at 15:52
  • It just need to change to Java 8 in the build.xml, check my answer below. No need to change your Java or Ant version! – Wagner Leonardi Mar 20 '15 at 01:39

2 Answers2

0

Do you have java sdk/JDK installed in your mac? you may try javac -version in your terminal and check the results.

you can also refer to http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html

Shouqun
  • 746
  • 4
  • 3
  • I had the same problem, and I know the question is old, but if you got curious, I solve this changing the build file to build with Java 8 too – Wagner Leonardi Mar 20 '15 at 01:37
0

Easy to solve, look at error message:

.../sdk/tools/ant/build.xml:734: Class not found: javac1.8

So open this file, on line 734, and you find fork="${need.javac.fork}"> . What's need.javac.fork? I don't know, but let's search this in document and we got this on line 199:

<condition else="false" property="need.javac.fork">
      <and>
          <matches pattern="1\.[56]" string="${java.specification.version}"/>
          <not>
              <os family="unix"/>
          </not>
      </and>
  </condition>

Whoa, pattern="1\.[56]" ?? It looks like this pattern is about Java 1.5 and 1.6, what If I change this to pattern="1\.[8]" ? Now it will build and works like a charm!!!

Some people said this is related because the ant version is old and doesn't support Java 8..or you need to install Java 1.6.. and yes doing this works too, but we programmers need to read error messages and be at least a little bit curious to understand and try to solve too, I spent a minute or two to find and solve this problem... just by reading the error message!

Wagner Leonardi
  • 4,226
  • 2
  • 35
  • 41