电脑重新装了JDK17,之前的项目就跑不起来了,一直报错:如下
What went wrong:
Execution failed for task ':sdk:generateDebugRFile'.
> Could not resolve all files for configuration ':sdk:debugCompileClasspath'.
> Failed to transform annotation-experimental-1.4.0.aar (androidx.annotation:annotation-experimental:1.4.0) to match attributes {artifactType=android-symbol-with-package-name, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: F:\whhnew\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.4.0\c7a2038d831d0cfbfb9a440890b287c2e839ecf\annotation-experimental-1.4.0.aar.
> Failed to transform 'F:\whhnew\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.4.0\c7a2038d831d0cfbfb9a440890b287c2e839ecf\annotation-experimental-1.4.0.aar' using Jetifier. Reason: Unsupported class file major version 61. (Run with --stacktrace for more details.)
java.lang.IllegalArgumentException: Unsupported class file major version 61
指定JDK11,也不行
后来就把gradle版本升级:
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.5-bin.zip
classpath 'com.android.tools.build:gradle:7.3.1'
就不报那个错误了,但是又报其他错误:
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotl
添加:
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
就好了,可以跑起来了