This project demonstrates How we can improve Android build times & have better Android Studio performance using local maven repository approach.
- Build & publish AAR artifacts to local maven repository by using
./gradlew publishAarPublicationToMavenRepository -PuseAARForDevBuild=false
- You should be able to see the folder name
localMavenRepositoryin your root directory. As the name suggests, this is your local maven repository and you should be able to see all artifacts under it.
- Add
useAARForDevBuild=truein yourlocal.properties(in your project's root directory) - Also specify modules on which you want to work, e.g. it should look like this
useAARForDevBuild=true
modules=:app :myawesomemodule1 :myawesomemodule2
-
Do gradle sync
-
Once sync is complete, check
Android Viewof project inAndroid Studio -
That's it, you can try adding / removing modules names and syncing same.
https://www.youtube.com/watch?v=rNT9eS5pO-g
- Add below in your project root level
build.gradle
apply from: "$rootDir/gradle/local-aar-config.gradle"
apply from: "$rootDir/gradle/local-aar.gradle"
- Also, specify local maven repo in your project root level
build.gradle
maven { url = "$rootDir/localMavenRepository" }
- Add below files to root level
gradledirectory
gradle/local-aar.gradle
gradle/local-aar-config.gradle
gradle/publish.gradle
gradle/settings-helper.gradle
- In your
settings.gradle, add below
apply from: "$rootDir/gradle/settings-helper.gradle"- In your
settings.gradle, replace included modules entries like this for all modules. e.g. replace
include ':awesomeModule1'with
includeIfEnabled(':awesomeModule1')- In your app modules
build.gradlefiles, add below
apply from: "$rootDir/gradle/local-aar.gradle"- In your library modules
build.gradlefiles, add below
apply from: "$rootDir/gradle/local-aar.gradle"
apply from: "$rootDir/gradle/publish.gradle"- Specify your dependencies path using
customModulePathmethod in yourbuild.gradlefiles. e.g. replace
implementation project(path: ':myawesomemodule1')with
implementation customModulePath(':myawesomemodule1')- Add
/localMavenRepositoryin your.gitignore - Follow How to run this demo section for building with this approach.