在使用Androidstudio自帶的創建activity及配套 xml時,構建項目失敗,報錯内容:
Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=androidx.activity:activity:1.8.0, variantName=null, artifactFile=C:\Users\hhhh\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.8.0\4266e2118d565daa20212d1726e11f41e1a4d0ca\activity-1.8.0.aar, extractedFolder=null, dependencyType=ANDROID, isWrappedModule=false, buildMapping={__current_build__=E:\ParaMonitor}, mavenCoordinatesCache=com.android.build.gradle.internal.ide.dependencies.MavenCoordinatesCacheBuildService$Inject@2817c711)
在terminal運行: .\gradlew compileDebugSources --stacktrace -info
* What went wrong: Execution failed for task ':app:checkDebugAarMetadata'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform activity-1.8.0.aar (androidx.activity:activity:1.8.0) to match attributes {artifactType=android-aar-m etadata, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for JetifyTransform: C:\Users\hhhh\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.8.0\4266e2118d565daa20212d1726e11f41e1a4d0ca\activity-1.8.0.aar. > Failed to transform 'C:\Users\hhhh\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.8.0\4266e2118d56 5daa20212d1726e11f41e1a4d0ca\activity-1.8.0.aar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 61. (Run with --stacktrace for more details.) Suggestions:
androidstudio自動構建的時候,默認選擇的是最新的包導入,但我原本使用的compileSdkVersion 33,1.8.0建议的依赖项compilesdk>=34;
我的解决方法:删掉导入的 implementation 'androidx.activity:activity:1.8.0'
java - 依赖项“androidx.activity:activity:1.8.0”要求依赖它的库或应用针对 Android API 版本 34 或更高版本进行编译 - 堆栈溢出 (stackoverflow.com)