Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android gradle build: running assembleDebug makes release tasks of project dependencies being called

When running assembleDebug, the release related tasks of projects I depend on are called.

e.g. I have a project called 'x' which depends on 'y'.

When I gradle assembleDebug it calls y:mergeReleaseProguardFiles, packageReleaseAidl, etc... etc..

like image 580
Guy Avatar asked Aug 07 '13 13:08

Guy


People also ask

How do I speed up Gradle task assembleDebug?

Enable build caching For example, ./gradlew assembleDebug --build-cache . You can also configure build caching on your gradle. properties file. Estimates that this will improve your full clean build by up to 3 times faster, and incremental builds by up to 10 times faster!

How long does Gradle task assembleDebug take?

will take 10-12 mins after that it will be good to go.

What is Gradle build running in Android Studio?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.


1 Answers

Edit: Not true anymore, with Android Gradle Plugin 3.x.

The libraries also publish debug and release artifacts. If the project has flavors or custom types, those are also created. And across modules, it tries to automatically match variants. If not matched, you need to provide matchingFallback to match variants across modules. More info can be found here: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#resolve_matching_errors


Android library modules publishes only "release" build type. They don't have "debug" build type. Even your application module build the debug version, it will use the release version of the library.

You can enable "debug" build type of the library dependency using the following in your module's build.gradle file:

android {
  publishNonDefault true
  ...
}

Then when you are using that dependency in the other module, you should use like this:

dependencies {
  releaseCompile project(path: ':moduleY', configuration: 'release')
  debugCompile project(path: ':moduleY', configuration: 'debug')
}

I am using the same trick in my application. I have a shared module and I use debug version of the module. Find details here:

https://github.com/pomopomo/WearPomodoro/blob/develop/mobile/build.gradle#L90

like image 165
tasomaniac Avatar answered Sep 22 '22 04:09

tasomaniac