【问题标题】:Android assembleRelease Failed with Error: Unsupported class version number [53.0] (maximum 52.0, Java 1.8)Android assembleRelease 失败并出现错误:不支持的类版本号 [53.0](最大 52.0,Java 1.8)
【发布时间】:2020-09-25 08:16:59
【问题描述】:
  • Android Studio 4.0.1
  • gradle-wrapper.properties:distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
  • build.gradle:
dependencies {
    classpath "com.android.tools.build:gradle:3.0.0"
    
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

组装发布apk时,失败并出现错误:

警告:处理任务时出现异常 java.io.IOException:不能 读 [C:\Users\derek_y\AppData\Local\Android\Sdk\platforms\android-30\android.jar] (无法处理类 [android/annotation/Nullable.class](不支持 类版本号 [53.0](最大 52.0,Java 1.8))) :app:transformClassesAndResourcesWithProguardForRelease 失败

FAILURE:构建失败并出现异常。

为什么 android-30\android.jar 需要 Java 版本 53.0 (Java 9)? Android Studio 4.0.1 不支持 Java 9 对吧?

附: 我试过了

  • gradle-wrapper.properties:distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
  • build.gradle:
dependencies {
    classpath "com.android.tools.build:gradle:4.0.1"
    
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

但是运行编译后的 apk 触发了另一个来自第三方 SDK 的错误:

java.lang.VerifyError: Rejecting class a.b.c because it failed compile-time verification

我想要快速修复,并且请求第三方更新需要时间,所以目前这无济于事。或者任何人都可以解释为什么会发生此 VerifyError 以及如何解决它?

非常感谢。

【问题讨论】:

    标签: android android-gradle-plugin android-studio-4.0


    【解决方案1】:

    这似乎是 Android Gradle 插件 (issue 77587908) 中的问题。它已在 AGP 3.3.0 中修复。

    尝试将 AGP 升级到 3.3.0 而不是 4.0.1:

    classpath "com.android.tools.build:gradle:3.3.0"
    

    这可能足以解决您的问题而不会引入其他问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-15
      • 1970-01-01
      • 2017-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-23
      相关资源
      最近更新 更多