- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近下载了Android Studio Bumblebee它询问了我是否想升级到 Android Gradle Plugin 7.1.0,这是与 Android Studio Bumblebee 一起发布的版本,这很有帮助。
升级后,我得到一个构建错误:
Unable to load class 'com.android.build.api.extension.AndroidComponentsExtension'.
This is an unexpected error. Please file a bug containing the idea.log file.
看着
idea.log
文件,我看到:
A problem occurred evaluating project ':main'.
at org.gradle.initialization.exception.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:103)
...
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':main'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
...
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:73)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:42)
...
Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension
这意味着我无法运行我的应用程序,我需要降级 AGP 7.0 才能让一切恢复正常。如何解决此问题并升级到 Android Gradle Plugin 7.1.0?
最佳答案
更新导航安全参数
这些行是要查看的重要行:
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:73)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:42)
这表明错误来自
Navigation Safe Args plugin 。
AGP APIs that the Navigation Safe Args Gradle plugin depend on have been removed. AGP 7.1 does not work with Navigation Safe Args versions 2.4.0-rc1 or 2.4.0, but will work with versions 2.5.0-alpha01 and 2.4.1. In the meantime, as a workaround, you can use AGP 7.1 with a snapshot build of Navigation Safe Args, Navigation 2.5.0-SNAPSHOT. To use the snapshot build, follow the snapshot instructions with build id #8054565.
Backported from Navigation
2.5.0-alpha01
: Safe Args now depends on Android Gradle Plugin version 7.0.4. This means that Navigation Safe Args will no longer be compatible with Android Studio versions prior to 7.0, but is now compatible with Android Gradle Plugin 7.1.0 and higher.
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
// Update this line to use 2.4.1
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.1"
}
请注意,您应始终使用与 Safe Args 插件相同版本的 Navigation 库(即,您的应用程序也应使用 Navigation 2.4.1):您不应尝试将 Navigation 2.4.1+ Safe Args 插件与早期版本一起使用Navigation 的版本(例如 2.3.5)。
classpath "com.google.firebase:perf-plugin:1.4.0"
使用
idea.log
的状态:
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at com.google.firebase.perf.plugin.FirebasePerfClassVisitorFactory.registerForProject(FirebasePerfClassVisitorFactory.java:54)
at com.google.firebase.perf.plugin.FirebasePerfPlugin.perform(FirebasePerfPlugin.java:145)
at com.google.firebase.perf.plugin.FirebasePerfPlugin.lambda$apply$0(FirebasePerfPlugin.java:107)
根据
Firebase Perf Plugin 1.4.1 Release Notes :
Migrated away from the deprecated Android Gradle plugin APIs.
classpath "com.google.firebase:perf-plugin:1.4.1"
关于android - 升级 Android Gradle 插件 7.1 后无法加载类 AndroidComponentsExtension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70857476/
我最近下载了Android Studio Bumblebee它询问了我是否想升级到 Android Gradle Plugin 7.1.0,这是与 Android Studio Bumblebee 一
我使用 Jetpack Compose 的第一个项目出现了这样的错误,我该如何解决 Unable to find method ''voidcom.android.build.api.extensio
我是一名优秀的程序员,十分优秀!