Unsupported major.minor version 52.0 in my app

后端 未结 28 2205
心在旅途
心在旅途 2020-11-28 03:43

I\'m trying to compile my Android project and I\'m getting this error

[INFO] Exception in thread \"main\" java.lang.UnsupportedClassVersionError: com/android         


        
相关标签:
28条回答
  • 2020-11-28 04:10

    What no one here is saying is that with Build Tools 24.0.0, Java 8 is required and most people have either 1.6 or 1.7.

    So yeah, setting the build tool to 23.x.x would 'solve' the problem but the root cause is the Java version on your system.

    On the long term, you might want to upgrade your dev environment to use JDK8 to make use the new language enhancements and the jack compiler.

    0 讨论(0)
  • 2020-11-28 04:10

    I just encountered this problem.

    Reverting from the "Preview Channel" versions of the SDK tools and build tools to the latest stable version fixed it.

    0 讨论(0)
  • 2020-11-28 04:10

    I'd had this issue for too long (SO etc hadn't helped) and only just solved it (using sdk 25).

    -The local.properties file proguard.dir var was not applying with ant; I'd specified 5.3.2, but a command line call and signed export build (eclipse) was using 4.7, from the sdk dir(only 5+ supports java 8)

    My solution was to replace the proguard jars (android-sdk/tools/proguard/libs directory) in the sdk with a current (5+) version of proguard.

    0 讨论(0)
  • 2020-11-28 04:11

    Got the same issue outside of Android Studio, when trying to build for Cordova using the sdk from command line (cordova build android).

    The solution provided by Rudy works in this case too. You just don't downgrade the version of Build Tools from Android Studio but you do it using the android sdk manager ui.

    0 讨论(0)
  • 2020-11-28 04:13

    This problem stems from the fact that your build tool version and JDK won't work together. I was using JDK version 7 with build tool 24.0.1. Of course lowering build tool version may fix the problem but it is not a real fix, as upgrading your build tools in future will break it again.

    You should make sure build tool version and JDK work together. I upgraded my build tool to latest (24.0.1) and installed jdk8. Make sure to set your JAVA_HOME to latest and then try clean build.

    0 讨论(0)
  • 2020-11-28 04:14

    I had two versions of java jdk installed. Once I pointed to right version of java jdk in File->Project Structure -> SDK Location to the latest version which I had in JAVA_HOME environment variable, the issue went away.

    0 讨论(0)
提交回复
热议问题