【问题标题】:Is there a way you can add repositories to android module (Library)有没有办法可以将存储库添加到 android 模块(库)
【发布时间】:2021-12-29 16:07:25
【问题描述】:
首先,我正在 android studio 上开发一个 android 应用程序,在该应用程序项目中,我还在开发一个我想保留为库的模块(我将在其他应用程序中需要它)
未来的项目)。这个模块自己有一些依赖,其中一些需要在项目级别的 gradle 构建脚本或 gradle 属性文件中添加其他 repos 以获取更新版本的 gradle。
有没有办法只添加repos模块,所以下次我想重用它时,我不必事先添加repos?
【问题讨论】:
标签:
android
gradle
repository
【解决方案1】:
经过大量搜索,我发现我可以在模块级别 build.gradle 脚本上添加存储库。
buildscript {
repositories {
google()
mavenCentral()
// Other repos here ....
}
}
plugins {
id 'com.android.library'
}
android {
compileSdk 31
defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
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 {
...
}
一切都像魅力一样。