After modularizing my app, when trying to make a release build, gradle always seems to be getting stuck on transforming a .aar file, though it doesn't for debug builds.
This is the step it gets stuck on, when I do gradlew assembleRelease
Transforming [LibraryName].aar (project :lib:library) with DexingNoClasspathTransform > DexingNoClasspathTransform [LibraryName]-runtime.jar
The .aar file is included in its own module
build.gradle
configurations.maybeCreate("default")
artifacts.add("default", file('[LibraryName].aar'))
This module has nothing else, and is required by a different module.
Everything worked fine, until the time came to make a release build. Can anyone help with this?
I managed to fix it, by changing the way I import it, and by enabling minification.
In settings.gradle, I added
flatDir {
dirs 'libs'
}
to
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
flatDir {
dirs 'libs'
}
}
}
Then in the build.gradle of the module that actually made use of the aar file (rather than a separate module just to import it)
implementation(name: 'AJVoIP', ext: 'aar')
Finally, in build.gradle for :app, I set minifyEnabled to true
release {
minifyEnabled true
crunchPngs true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
This in itself solved the problem, but build times were very slow (13+ minutes)
Adding this to gradle.properties reduced build times up a lot.
android.enableR8.fullMode=true