Can the Android SDK work with JDK 1.7?

I just installed the Android SDK R16 and JDK 7, but I keep getting the error

Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties."

I am using some features of the JRE 1.7, so I can't just switch it to 1.6. How can I fix this problem?


You just need 1.6 present on your PC. I had the same problem. Install 1.6 JDK, and add it as known JDK, but don't actually select it for your project.


Yes, you can use Java 1.7 for the Android development. You must keep source compatibility with Java 6 during compile and only the next problem is because of the changed default algorithm for jarsigner.

This is solved in Stack Overflow question Android signing with Ant (workaround).

But it is already fixed in Ant. So the official support will be directly in the Android SDK soon.

If you want to use Maven for the build, the solution is in What kind of pitfals exist for the Android APK signing.

Update: Latest version of Ant, Maven Plugin or Gradle has no problem with Java 7 or Java 8, so this is already obsolete.


Starting with the ADT (22.6), it's possible to use Java 1.7 functionalities:

  • http://developer.android.com/tools/sdk/eclipse-adt.html
  • http://tools.android.com/recent/eclipseadt226preview
  • IMPORTANT:

    The try-with-resources needs API 19 and above:

    Added support for Java 7 language features like multi-catch, try-with-resources, and the diamond operator. These features require version 19 or higher of the Build Tools. Try-with-resources requires minSdkVersion 19; the rest of the new language features require minSdkVersion 8 or higher.

    链接地址: http://www.djcxy.com/p/17970.html

    上一篇: Android Studio和Gradle中的源代码1.7

    下一篇: Android SDK可以使用JDK 1.7吗?