apply plugin: 'dagger.hilt.android.plugin' //基类的gradle配置 kapt { //ARouter的编译配置 arguments { arg("AROUTER_MODULE_NAME", project.getName()) } } android { compileSdk versions.compileSdk defaultConfig { minSdk versions.minSdk targetSdk versions.targetSdk versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'consumer-rules.pro' multiDexEnabled true vectorDrawables.useSupportLibrary = true javaCompileOptions { //Hilt的编译配置 annotationProcessorOptions { arguments += ["foo": "bar"] } } } buildTypes { release { minifyEnabled false multiDexKeepProguard file('multidex-config.pro') proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { multiDexKeepProguard file('multidex-config.pro') } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { freeCompilerArgs = ['-Xjvm-default=enable'] jvmTarget = JavaVersion.VERSION_1_8 useIR = true } lintOptions { checkReleaseBuilds false } packagingOptions { resources { excludes += '/META-INF/{AL2.0,LGPL2.1}' } } } configurations.all { resolutionStrategy.force 'androidx.multidex:multidex:2.0.1' resolutionStrategy.force 'androidx.annotation:annotation:1.2.0' resolutionStrategy.force 'androidx.transition:transition:1.3.1' resolutionStrategy.force 'androidx.lifecycle:lifecycle-common:2.3.1' resolutionStrategy.force 'androidx.recyclerview:recyclerview:1.2.0' } //ARouter和Hilt的配置都写在了最底层 dependencies { api fileTree(dir: 'libs', include: ['*.jar']) //每个模块都要实现的依赖 //Test testImplementation deps.android.junit androidTestImplementation deps.android.test_junit androidTestImplementation deps.android.test_espresso //依赖注入 implementation deps.support.hilt kapt deps.support.hilt_kapt //ARouter路由 implementation(deps.support.arouter) { exclude group: 'com.android.support' exclude group: 'androidx.appcompat' exclude group: 'com.google.android.material' exclude group: 'androidx.activity' } //ARouter的注解处理器 kapt deps.support.arouter_kapt }