16

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..

Guy
  • 12,250
  • 6
  • 53
  • 70
  • I'm also confused about this. You haven't happened to gotten this answered now (seeing this was over a year ago)? If I build several of the modules by themselves, as in :moduleA:assembleDebug, :moduleB:assembleDebug the only release related task is preReleaseBuild (which for some reason is part of assembleDebug so that should be normal), but when I do :moduleX:assembleDebug (which depends on moduleA/B) lots of release tasks are called, like you experienced. The reason I care is because it seems this makes buildTypes { release { runProguard true being used which I don't want for debug build. – riper Oct 27 '14 at 18:08
  • Yes, never got an answer :) – Guy Oct 27 '14 at 19:51
  • Does this happen for any build file (say creating a new blank project in Android Studio) or is it only with specific build files? If the latter, please edit your question and add details. Also, how are you determining that the release tasks are being run? – Scott Barta Oct 28 '14 at 00:16
  • Hi Scott. We are still developing with Eclipse, but using gradle for our production bulids, hence we've written our build files manually. When building an :assemgleRelease target I see the following tasks are being called for various modules: preDebugBuild, preDebugTestBuild – Guy Oct 28 '14 at 11:14
  • @Guy in that case you should attach your build files to your question. – Scott Barta Oct 28 '14 at 15:56
  • @riper did you try posting in the adt-dev mailing list? they can be pretty responsive some times, and are always very nice and professional. – Guy Nov 04 '14 at 06:33
  • @Guy No haven't, mailing lists seem so 1999, but maybe I should give it a try. I bet Xavier D knows the answer. – riper Nov 10 '14 at 22:01
  • 2
    @Guy I got an answer from Xavier! :) He also linked to an existing issue which is this one: https://code.google.com/p/android/issues/detail?id=52962 Hopefully a fix in Gradle for this will come soon. Btw, who got the 48p the bounty was worth? I lost them at least, I thought I would need to approve an answer for someone to get the bounty. – riper Nov 22 '14 at 16:24
  • @riper ive never set a bounty... Am i misunderstanding something? – Guy Nov 22 '14 at 16:37
  • @Guy No you didn't, but I did on your question. :) And then I figured I would be the one who decided if some answer deserved the 50p. I never did, the bounty expired (after 7 days) but I still lost 48p (not sure why it wasn't 50p either). I would assume I wouldn't lose any points (reputation) at all. That's why I'm confused. – riper Nov 23 '14 at 10:10
  • @Guy Are you still seeing this? – Jared Burrows Apr 04 '15 at 02:13
  • This is a limitation in Gradle and they are looking into fixing this. It is still open as of Android Studio 1.4 – anthonymonori Nov 18 '15 at 08:24

1 Answers1

4

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

tasomaniac
  • 10,234
  • 6
  • 52
  • 84