今天刚注意到Arctic Fox 有Beta 4 的更新。之前测试没有问题,我决定升级我的Beta 3。和往常一样,AGP 也需要升级。在我尝试使用新的 Gradle n AGP 构建我的项目之前,新的 Beta 版似乎运行良好。 每次都遇到此错误,除了恢复到 Arctic Fox beta 3 或其正常发行版之外,我尝试过的任何内容(包括消息中建议的步骤)都不起作用。想知道这里是否有人知道原因并对此有解决方案
Unable to find method com.android.build.api.extension.VariantSelector com.android.build.api.extension.AndroidComponentsExtension.selector()
com.android.build.api.extension.VariantSelector com.android.build.api.extension.AndroidComponentsExtension.selector()
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
答案 0 :(得分:1)
如果您使用的是 Hilt,那么您必须等待 AGP 7 beta05。
Link to Hilt issue here
答案 1 :(得分:0)
如前所述,您必须等待 Android Gradle 插件 7.0.0-beta05 要么 您可以使用 7.1.0 Alpha。
这对我有用
dependencies {
classpath("com.android.tools.build:gradle:7.1.0-alpha02")
...
object LibsHilt {
const val version = "2.37"
private const val versionX = "1.0.0"
const val hilt = "com.google.dagger:hilt-android:$version"
const val compiler = "com.google.dagger:hilt-android-compiler:$version"
const val viewModel = "androidx.hilt:hilt-lifecycle-viewmodel:$versionX"
const val compilerX = "androidx.hilt:hilt-compiler:$versionX"
object Dagger {
const val version = "2.37"
const val dagger = "com.google.dagger:dagger:$version"
const val compiler = "com.google.dagger:dagger-compiler:$version"
}
object Test {
const val testing = "com.google.dagger:hilt-android-testing:$version"
const val compiler = "com.google.dagger:hilt-android-compiler:$version"
}
}
{PROJECT_ROOT}/gradle/wrapper/gradle-wrapper.properties
:...
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
...
答案 2 :(得分:0)
对我来说,最简单、最快速的工作解决方案是下载最新的 Canary 版本及其最前沿的依赖项,并使用它编译我的项目。
如果前进更好,我就不应该回去:D