First of all, I'm working on an android application on android studio, within that app project I'm working also on a module that I want to keep as a library (I'll need it in other future projects). This module has some dependencies for it own, and some of them require the addition of other repos on the project level gradle build script or on the gradle propertis file for newer version of gradle.
Is there a way that I can add repos the module only, so the next time when I want to reuse it, I'll not have to add the repos beforehand ?
CodePudding user response:
After a lot of search here and there, I found that I can add repositories on module level build.gradle
script.
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 {
...
}
and Everything works like a charm.