Android Studio UNEXPECTED TOP-LEVEL EXCEPTION:

前端 未结 3 820
失恋的感觉
失恋的感觉 2021-01-14 05:04

Today I am faced with a massive error that doesn\'t let me run a sample project on my phone.

When Android Studio is building the project, it first shows the followin

3条回答
  •  礼貌的吻别
    2021-01-14 05:16

    Because it is reporting: bad class file magic (cafebabe) or version (0034.0000) you should check if you are compiling with the same java version that you are trying to use at runtime. If you are using gradle you should use the following or similar entries in your build.gradle file:

    apply plugin: 'java'
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
    

    Use this link for more gradle details.

    In Android Studio, from File -> Project Structure -> SDK Location -> JDK Location you should use the jdk 1.7 and not relay on the Project level setting. See this link for a similar Android Studio question.

提交回复
热议问题