最佳答案
我最近下载了 安卓工作室大黄蜂,它很有帮助地询问我是否想要升级到 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 Plugin7.1.0?