其他分享
首页 > 其他分享> > hilt

hilt

作者:互联网

hilt

build.gradle中配置

buildscript {
    ext {
		// ...
        hiltVersion = "2.38.1"
        hiltCompilerVersion = "1.0.0"
        hiltComposeVersion = "1.0.0-alpha03"
    }
    dependencies {
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
    }
}

build.gradle:app中配置

plugins {
    id "kotlin-kapt"
    id "dagger.hilt.android.plugin"
}

dependencies {
    // hilt
    implementation "com.google.dagger:hilt-android:$hiltVersion"
    kapt "com.google.dagger:hilt-compiler:$hiltVersion"
    implementation "androidx.hilt:hilt-navigation-compose:$hiltComposeVersion"
    implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hiltComposeVersion"
    kapt "androidx.hilt:hilt-compiler:$hiltCompilerVersion"
}

程序入口配置

@HiltAndroidApp
class MyApplication : MultiDexApplication() {
    // ...
}

标签:kapt,google,dagger,androidx,hiltVersion,hilt
来源: https://www.cnblogs.com/poifa/p/16319525.html