Unsupported major.minor version 52.0 in my app

后端 未结 28 2207
心在旅途
心在旅途 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:02

    Initially I had downgraded buildToolsVersion from 24.0.0 rc3 to 23.0.3, as specified in Rudy Kurniawan's answer. Then I have noticed that I have jdk 7 specified in my project settings. I have changed it to jdk 8 and now build tools 24.0.0 rc3 work.

    It's also important to have compile options set to java7:

    android {
        ...
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }
    
    0 讨论(0)
  • 2020-11-28 04:03

    I am on Android Studio 2.0 and facing the same problem. The solution provided by Rudy Kurniawan sorted out this issue. The affected file can be located by:

    "Project" -> "Android" -> "Gradle Scripts" -> "build.gradle(Module:app)"

    The "Project" pane is default on the left. To find it, inspect the name of the side tabs, click it, then use the top pull down box to get to "Android". Expand the tree in the pane to find the target file. Double-click it to edit.

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

    In my case the default jdk was 1.7 then I changed it to 1.8 by browsing to the exact folder where the updated jdk is found in.

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

    Get this error message on the travis build server?

    I fixed my travis build with buildToolsVersion "24.0.2" using this

    # travis build 
    language: android
    
    jdk:
      - oraclejdk8
    
    android:
      components:
        - tools
        - build-tools-24.0.2
        - android-23
    
        - add-on
        - extra
    
    script:
      - jdk_switcher use oraclejdk8
      - ./gradlew assemble
    
    0 讨论(0)
  • 2020-11-28 04:06

    Sorry for the late reply.Hope it helps someone else

    This problem is related with your SDK, not with your JDK. You can check your version information from

    Help > About > Show Details

    You will get something like

    Xamarin.Android Version: 6.0.2.1 (Starter Edition) Android SDK: X:\Android\android-sdk

    Supported Android versions:

    4.0.3 (API level 15)

    4.4 (API level 19)

    6.0 (API level 23)

    SDK Tools Version: 24.4.1

    SDK Platform Tools Version: 23.0.1

    SDK Build Tools Version: 24 rc2

    Java SDK: X:\Program Files (x86)\Java\jdk1.7.0_71

    java version "1.7.0_71"

    Java(TM) SE Runtime Environment (build 1.7.0_71-b14)

    Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)

    If you are using preview tools for building ,then you will get similar errors all over.

    What to do now?

    goto

    Tools -> SDK manager

    1. Select all items in preview channels including Android SDK build tools with rev 24rc2 or 24rc4(latest)

    2. Click on Delete 'n' packages

    How to turn off preview channel

    1. In SDK manager, select

      Tools > options

    2. Uncheck Enable preview tools

    And what

    Back to your code Clean all and rebuild (In rare cases, you have to select build-tools from project settings page)

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

    Your Android build tools are not properly installed. Try installing some other version of build tools and give that version in the gradle file. or you can go to this directory

    C:\Users\\AppData\Local\Android\sdk\build-tools

    and see which build tools is installed. Try changing the build tool version in the gradle file and compile the app to see if it is working.

    i had 22.0.1,23.0.02 and 24.0.0 versions of build tools and only the old 22.0.1 version worked.

    source: i tried it myself and it worked for me.

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