Unsupported major.minor version 52.0 in my app

后端 未结 28 2265
心在旅途
心在旅途 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 03:54

    Gradle Scripts >> build.gradle (Module app)

    Change buildToolsVersion "24.0.0" to buildToolsVersion "23.0.3"

    source : experience

    0 讨论(0)
  • 2020-11-28 03:57

    I installed Android Studio alongside to Xamarin Visual Studio (was already installed). After the installation (excluded SDK, because they were already installed) I started Android Studio and it downloaded, installed and added missing SDKs (after giving the path to the SDK location). As a result I got the error message on build

    java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

    As a solution I installed jdk-8u101-windows-i586.exe without JRE (because it was already installed). Before I tried the x64 version, but it disappeared ... Then you have to change the Java Development Kit location.

    This is done in Visual Studio by clicking Tools > Options > Xamarin > Android Settings. Here you can navigate to the correct location. In my case it was C:\Program Files (x86)\Java\jdk1.8.0_101.

    Finally, clean your project and make a new build :-)

    0 讨论(0)
  • 2020-11-28 03:57

    I also faced this problem when making a new project in eclipse.

    1. Open your eclipse installation directory
    2. Open the file eclipse.ini
    3. Modify

      Dosgi.requiredJavaVersion=1.6 
      

      to

      Dosgi.requiredJavaVersion=1.7
      

    Hope this helps

    0 讨论(0)
  • 2020-11-28 03:58

    From this question.

    You can try to change your compiler level back to 1.7 in the IDE you're using.

    • If you're on Eclipse, go to Windows ---> Prefences then select Java and expand it then select Compiler and change the compliance level to 1.7.
    • If you're on Android Studio, you can add this to your build.gradle

      android {
          compileSdkVersion 19
          buildToolsVersion "19.0.0"
      
          defaultConfig {
              minSdkVersion 7
              targetSdkVersion 19
          }
      
          compileOptions {
              sourceCompatibility JavaVersion.VERSION_1_7
              targetCompatibility JavaVersion.VERSION_1_7
          }
      }
      

    If this doesn't help, try checking other's answer in the link mentioned above and let us know what helped you.

    0 讨论(0)
  • 2020-11-28 03:59

    The problem specified:

    Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.

    is caused when is declared inside the build.gradle, buildToolsVersion 24 and we don´t have Java 8 installed that is required for this version. To solve this problem we have to change from buildToolsVersion from 24 to maximum 23:

    Java 8 must be required in the future for Android Studio, so we have to start using Java 8.

    0 讨论(0)
  • 2020-11-28 03:59

    52 is the code for JDK 8. You can see that here: http://javarevisited.blogspot.com/2015/05/fixing-unsupported-majorminor-version.html. So Gradle is expecting you to have JDK 8 as the default Java version on your machine. Newest versions of Gradle for Android won't work with Java 7.

    The solution is simple: make Java 8 the default jdk version on your machine.

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