Android gradle 7.0+完整配置记录
1.根目录 settings.gradle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | pluginManagement { repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' allowInsecureProtocol = true //这个是新增的 } maven { url 'https://jitpack.io' allowInsecureProtocol = true } gradlePluginPortal() google() mavenCentral() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { //华为maven maven { url "http://developer.huawei.com/repo/" allowInsecureProtocol = true } // maven { // url "http://xxxxxxxx/repository/maven-public/" // allowInsecureProtocol = true // } // maven { url "https://jitpack.io" } google() mavenCentral() } } rootProject.name = "HiltDemo" include ':app' |
2.根目录build.gradle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | //注意 buildscript节点有可能没有 自己添加需要注意与plugins的顺序 buildscript { ext { kotlin_version = '1.6.10' } dependencies { classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha' } } plugins { id 'com.android.application' version '7.1.1' apply false id 'com.android.library' version '7.1.1' apply false id 'org.jetbrains.kotlin.android' version '1.5.31' apply false } //apply from: "config.gradle"//自定义配置清单还是能够使用 task clean(type: Delete) { delete rootProject.buildDir } |
3.app或者module中的build.gradle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | plugins { //这里的变化就是将apply plugin改为id id 'com.android.application' // apply plugin: 'kotlin-kapt' // apply plugin: 'dagger.hilt.android.plugin' id 'org.jetbrains.kotlin.android' id 'kotlin-kapt' id 'dagger.hilt.android.plugin' } //apply from 'xxx.gradle'//可以正常使用 android { compileSdk 31 defaultConfig { applicationId "com.tdroid.hiltdemo" minSdk 28 targetSdk 31 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile( 'proguard-android-optimize.txt' ), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' implementation "com.google.dagger:hilt-android:2.28-alpha" kapt "com.google.dagger:hilt-android-compiler:2.28-alpha" } |
顺便记录一个阿里云的 maven地址
1 | https: //maven.aliyun.com/repository/google |
分类:
Android 源码学习
标签:
Android
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)