Skip to content

akhgupta/AndroidLocalMavenRepoAARDemo

Repository files navigation

This project demonstrates How we can improve Android build times & have better Android Studio performance using local maven repository approach.

Recommended for projects where we have more than one module.



Detailed info here

https://blog.gojekengineering.com/how-we-improved-performance-and-build-times-in-android-studio-306028166b79



How to run this demo ?


Publish local AAR artifacts

  1. Build & publish AAR artifacts to local maven repository by using
./gradlew publishAarPublicationToMavenRepository -PuseAARForDevBuild=false
  1. You should be able to see the folder name localMavenRepository in your root directory. As the name suggests, this is your local maven repository and you should be able to see all artifacts under it.

Specify dev modules to work on

  1. Add useAARForDevBuild=true in your local.properties (in your project's root directory)
  2. Also specify modules on which you want to work, e.g. it should look like this
useAARForDevBuild=true
modules=:app :myawesomemodule1 :myawesomemodule2
  1. Do gradle sync

  2. Once sync is complete, check Android View of project in Android Studio

  3. That's it, you can try adding / removing modules names and syncing same.



Demo Video

https://www.youtube.com/watch?v=rNT9eS5pO-g


How to integrate this approach in your app ?

  1. Add below in your project root level build.gradle
apply from: "$rootDir/gradle/local-aar-config.gradle"
apply from: "$rootDir/gradle/local-aar.gradle"
  1. Also, specify local maven repo in your project root level build.gradle
maven {   url = "$rootDir/localMavenRepository"   }
  1. Add below files to root level gradle directory
gradle/local-aar.gradle
gradle/local-aar-config.gradle
gradle/publish.gradle
gradle/settings-helper.gradle
  1. In your settings.gradle, add below
apply from: "$rootDir/gradle/settings-helper.gradle"
  1. In your settings.gradle, replace included modules entries like this for all modules. e.g. replace
include ':awesomeModule1'

with

includeIfEnabled(':awesomeModule1')
  1. In your app modules build.gradle files, add below
apply from: "$rootDir/gradle/local-aar.gradle"
  1. In your library modules build.gradle files, add below
apply from: "$rootDir/gradle/local-aar.gradle"
apply from: "$rootDir/gradle/publish.gradle"
  1. Specify your dependencies path using customModulePath method in your build.gradle files. e.g. replace
implementation project(path: ':myawesomemodule1')

with

implementation customModulePath(':myawesomemodule1')
  1. Add /localMavenRepository in your .gitignore
  2. Follow How to run this demo section for building with this approach.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published