After upgrading the new version of Android Studio, the location of the plug-in classpath cannot be found

Recently, the handicap has been upgraded Android Studioto a new version Android Studio Chipmunk, and I found that gradlethe version has been upgraded 7.4.2, gradle 插件and the version has been upgraded 7.2.0-alpha05. There was no problem at first, but today I want to join Hiltthis third-party library, and a problem arises.

Everyone knows that Hiltthe third-party library of this kind of giant bull fork is generally built with ASM+ APT+ 注解+ 反射+ 动态代理these underlying basic knowledge. Therefore, when using it APT, you need to use related gradleplug-ins.

Usually we use Hiltonly two steps:

  1. add hilt-android-gradle-pluginplugin;
  2. Add hilt-androiddependencies.

build.gradleUsually we can add Hilt-android-gradle-pluginplugin dependencies in the root directory of the project :


insert image description here
But now in the new version there build.gradleis no longer classpaththe position:


insert image description here
The writing method here is completely different from the old version, and it is Kotlin DSLwritten in grammar.
At this time, I need to add it Hiltto the project, but I can’t find classpaththe place to add it, which is more difficult. Through the search gradledocumentation:

https://docs.gradle.org/current/userguide/userguide.pdf

Then tell me that you only need to build.gradleadd the corresponding dependencies in the project root directory:

buildscript {
    
    
    repositories {
    
    
        mavenCentral()
    }

    dependencies {
    
    
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.42'
    }
}

Add it to the following places as shown in the figure:


insert image description here
Done.

Guess you like

Origin blog.csdn.net/u013762572/article/details/124775166