你可以在项目级别的build.gradle文件中使用以下依赖项:
id 'com.google.dagger.hilt.android' version '2.41' apply false
id 'androidx.navigation.safeargs' version '2.4.2' apply false
buildscript {
ext {
compose_version = '1.2.0-alpha04'
hilt_version = '2.41'
accompanist_version = '0.24.2-alpha'
}
dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'\
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0-alpha03' apply false
id 'com.android.library' version '7.3.0-alpha03' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
id 'com.google.dagger.hilt.android' version '2.41' apply false
id 'androidx.navigation.safeargs' version '2.4.2' apply false
plugins {
id 'androidx.navigation.safeargs'
id 'dagger.hilt.android.plugin'
}
首先,需要像编写要添加的插件一样进行生活,这里我展示了一个例子。
代码是id 'androidx.navigation.safeargs' version'2.4.2' apply false 你需要像下面这样写