Unable to build after upgrading to Android Studio Arctic Fox Beta 4

Viewed 3265

Just noticed today that Arctic Fox has an update to Beta 4. Having no issue before with betas, I decided to upgrade my Beta 3. As always, AGP needed to be upgraded as well. The new Beta seems to be working alright until I tried to build my project with the new Gradle n AGP. Got this error every time and nothing I tried (including the suggested steps in the message) works except reverting to Arctic Fox beta 3 or its normal release version. Wonder if anyone here has a clue why and have a solution for this

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.
3 Answers

As mentioned you have to wait for Android Gradle Plugin 7.0.0-beta05 OR you can use 7.1.0 Alpha.

This works for me

  1. Project's build.gradle:
    dependencies {
        classpath("com.android.tools.build:gradle:7.1.0-alpha02")
        ...
  1. Use the latest Hilt 2.37 (and Dagger if you need):
    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"
      }
    }
  1. File {PROJECT_ROOT}/gradle/wrapper/gradle-wrapper.properties:
...
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
...

The easiest and fastest working solution for me is downloading the latest Canary version along with its bleeding edge dependencies and compile my project using it.

If forward is better, I shouldn't go back :D

Related