Status Update
Comments
ch...@gmail.com <ch...@gmail.com> #2
can you share your android studio version
xa...@android.com <xa...@android.com> #4
Note: This worked for me on Windows 7 Pro 32-bit (with Android Studio 2.3.3). Seems like an issue with adt-branding module (which should contain the "/idea/AndroidStudioApplicationInfo.xml" resource).
ch...@gmail.com <ch...@gmail.com> #5
Hi, also happened on Mac Book Pro 15 retina mi-2015
MacOs Sierra 10.12.6
Android Studio 2.3.3
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
MacOs Sierra 10.12.6
Android Studio 2.3.3
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
xa...@android.com <xa...@android.com> #6
Thank you for this feedback. Your feedback helps make sure Android development tools are great! Given your issues has been resolved I am closing this issue.
ch...@gmail.com <ch...@gmail.com> #7
I am essentially doing the following, but programmatically; so I think the answer to your question is I am adding the dependencies as you wrote, just not individually by hand.
dependencies {
flavorXCompile(libraryA) {
artifact {
name = 'libraryA'
classifier = 'test'
type = 'jar'
}
}
flavorYCompile(libraryB) {
artifact {
name = 'libraryB'
classifier = 'test'
type = 'jar'
}
}
}
dependencies {
flavorXCompile(libraryA) {
artifact {
name = 'libraryA'
classifier = 'test'
type = 'jar'
}
}
flavorYCompile(libraryB) {
artifact {
name = 'libraryB'
classifier = 'test'
type = 'jar'
}
}
}
do...@gmail.com <do...@gmail.com> #8
It appears this is not limited to Google Play Services, but happens also when including any AAR, as in example attached.
Run ./gradlew :app:assembleAppFlavor1Debug and you will end up with following tasks reached:
$ ./gradlew :app:assembleAppFlavor1Debug
:app:preBuild
:app:preAppFlavor1DebugBuild
:app:compileAppFlavor1DebugNdk
:app:checkAppFlavor1DebugManifest
:app:preAppFlavor1ReleaseBuild
:app:preAppFlavor2DebugBuild
:app:preAppFlavor2ReleaseBuild
:app:preAppFlavor3DebugBuild
:app:preAppFlavor3ReleaseBuild
:app:prepareGradlePlay2MylibraryUnspecifiedLibrary // the culprit
:app:prepareAppFlavor1DebugDependencies
:app:compileAppFlavor1DebugAidl
:app:compileAppFlavor1DebugRenderscript
:app:generateAppFlavor1DebugBuildConfig
:app:generateAppFlavor1DebugAssets UP-TO-DATE
:app:mergeAppFlavor1DebugAssets
:app:generateAppFlavor1DebugResValues UP-TO-DATE
:app:generateAppFlavor1DebugResources
:app:mergeAppFlavor1DebugResources
:app:processAppFlavor1DebugManifest
:app:processAppFlavor1DebugResources
:app:generateAppFlavor1DebugSources
:app:compileAppFlavor1DebugJava
:app:preDexAppFlavor1Debug
:app:dexAppFlavor1Debug
:app:processAppFlavor1DebugJavaRes
:app:validateDebugSigning
:app:packageAppFlavor1Debug
:app:zipalignAppFlavor1Debug
:app:assembleAppFlavor1Debug
Run ./gradlew :app:assembleAppFlavor1Debug and you will end up with following tasks reached:
$ ./gradlew :app:assembleAppFlavor1Debug
:app:preBuild
:app:preAppFlavor1DebugBuild
:app:compileAppFlavor1DebugNdk
:app:checkAppFlavor1DebugManifest
:app:preAppFlavor1ReleaseBuild
:app:preAppFlavor2DebugBuild
:app:preAppFlavor2ReleaseBuild
:app:preAppFlavor3DebugBuild
:app:preAppFlavor3ReleaseBuild
:app:prepareGradlePlay2MylibraryUnspecifiedLibrary // the culprit
:app:prepareAppFlavor1DebugDependencies
:app:compileAppFlavor1DebugAidl
:app:compileAppFlavor1DebugRenderscript
:app:generateAppFlavor1DebugBuildConfig
:app:generateAppFlavor1DebugAssets UP-TO-DATE
:app:mergeAppFlavor1DebugAssets
:app:generateAppFlavor1DebugResValues UP-TO-DATE
:app:generateAppFlavor1DebugResources
:app:mergeAppFlavor1DebugResources
:app:processAppFlavor1DebugManifest
:app:processAppFlavor1DebugResources
:app:generateAppFlavor1DebugSources
:app:compileAppFlavor1DebugJava
:app:preDexAppFlavor1Debug
:app:dexAppFlavor1Debug
:app:processAppFlavor1DebugJavaRes
:app:validateDebugSigning
:app:packageAppFlavor1Debug
:app:zipalignAppFlavor1Debug
:app:assembleAppFlavor1Debug
do...@gmail.com <do...@gmail.com> #9
Apparently this can be fixed as original reporter suggested: in app's build.gradle
afterEvaluate {
prepareGradlePlay2MylibraryUnspecifiedLibrary.dependsOn.clear()
}
afterEvaluate {
prepareGradlePlay2MylibraryUnspecifiedLibrary.dependsOn.clear()
}
an...@gmail.com <an...@gmail.com> #10
Isn't there a better work-around than #9?
I had to add such statements on many modules so that gradle stops building all flavors all the time, but then everything fails after a clean!
I had to add such statements on many modules so that gradle stops building all flavors all the time, but then everything fails after a clean!
do...@gmail.com <do...@gmail.com> #11
So far I don't know any other workaround. The good part is that this workaround is required only in application modules, not library modules. Adding this to library modules can cause failure after a clean.
In my project I have multiple application modules that depend on different flavors of single library module (lib1). I also have another library module (lib2) that has got multiple flavors, each of it depending on specific flavor of lib1. Then, I have one application module that depends on both lib1 and lib2. This causes generating prepareLib1UnspecifiedLibrary task two times (once in lib2 and once in app). To ensure all flavors of both lib1 and lib2 don't get built in my app's build.gradle I had to add the following (assume app module is called MyApp):
afterEvaluate {
prepareMyAppLib1UnspecifiedLibrary.dependsOn.clear()
prepareMyAppLib2UnspecifiedLibrary.dependsOn.clear()
project(':lib2').prepareMyAppLib1UnspecifiedLibrary.dependsOn.clear()
}
In my case, everything works even after clean.
I really hope this will get fixed soon because this workaround is awful.
In my project I have multiple application modules that depend on different flavors of single library module (lib1). I also have another library module (lib2) that has got multiple flavors, each of it depending on specific flavor of lib1. Then, I have one application module that depends on both lib1 and lib2. This causes generating prepareLib1UnspecifiedLibrary task two times (once in lib2 and once in app). To ensure all flavors of both lib1 and lib2 don't get built in my app's build.gradle I had to add the following (assume app module is called MyApp):
afterEvaluate {
prepareMyAppLib1UnspecifiedLibrary.dependsOn.clear()
prepareMyAppLib2UnspecifiedLibrary.dependsOn.clear()
project(':lib2').prepareMyAppLib1UnspecifiedLibrary.dependsOn.clear()
}
In my case, everything works even after clean.
I really hope this will get fixed soon because this workaround is awful.
an...@gmail.com <an...@gmail.com> #12
For me, none of the workaround offered here actually work. If I try workaround in #11, the build will simply fail with missing dependencies.
I've managed to "make it work" by clearing the dependency on the various libraries and apps, but then the build will fail after a clean and I'll have to build everything twice to be able to run the latest changes.
Sadly without those, the build time (to run the debug version) is between 3 and 5 minutes, if not more at times! It's becoming awful and I long for the old Eclipse project which built the debug version in less than 30 seconds!
I've managed to "make it work" by clearing the dependency on the various libraries and apps, but then the build will fail after a clean and I'll have to build everything twice to be able to run the latest changes.
Sadly without those, the build time (to run the debug version) is between 3 and 5 minutes, if not more at times! It's becoming awful and I long for the old Eclipse project which built the debug version in less than 30 seconds!
do...@gmail.com <do...@gmail.com> #13
@14
does the workaround from #11 not working for you? While building your app, search through gradle output and find all tasks that have name prepareSomethingSomethingSomeVersion and clear dependencies of all those tasks in afterEvaluate block. If this causes some real project dependency not to be executed before your code, thus requiring you to build everything twice you can try as follows:
afterEvaluate {
prepareMyAppLib1UnspecifiedLibrary.dependsOn.clear()
prepareMyAppLib1UnspecifiedLibrary.dependsOn.add(dependencies.project(path: ':MyLibrary', configuration: 'release')
}
does the workaround from #11 not working for you? While building your app, search through gradle output and find all tasks that have name prepareSomethingSomethingSomeVersion and clear dependencies of all those tasks in afterEvaluate block. If this causes some real project dependency not to be executed before your code, thus requiring you to build everything twice you can try as follows:
afterEvaluate {
prepareMyAppLib1UnspecifiedLibrary.dependsOn.clear()
prepareMyAppLib1UnspecifiedLibrary.dependsOn.add(dependencies.project(path: ':MyLibrary', configuration: 'release')
}
pa...@gmail.com <pa...@gmail.com> #14
I did a little research. The real problem are the dependencies looking like:
prepareAndroidSupportV42311Library.dependsOn -> [Any dependent library]:bundleRelease,[Any dependent library]:bundleDebug
To get rid of building of all library variants, we have to clear the dependencies just of this tasks. I suggest to replace them with
prepareAndroidSupportV42311Library.mustRunAfter -> ([Any dependent library]:bundleRelease, [Any dependent library]:bundleDebug).
This way we still get the correct order of building the already scheduled tasks, but without the forcing the other dependencies.
At least this works for me.
prepareAndroidSupportV42311Library.dependsOn -> [Any dependent library]:bundleRelease,[Any dependent library]:bundleDebug
To get rid of building of all library variants, we have to clear the dependencies just of this tasks. I suggest to replace them with
prepareAndroidSupportV42311Library.mustRunAfter -> ([Any dependent library]:bundleRelease, [Any dependent library]:bundleDebug).
This way we still get the correct order of building the already scheduled tasks, but without the forcing the other dependencies.
At least this works for me.
ea...@google.com <ea...@google.com>
ra...@gmail.com <ra...@gmail.com> #15
Adding the closure below helped me.
afterEvaluate {
tasks.findAll { item ->
item.name.startsWith('prepare') && item.name.endsWith("Library") && item.name.contains("Unspecified")
}.each { item ->
item.dependsOn.clear();
}
}
afterEvaluate {
tasks.findAll { item ->
item.name.startsWith('prepare') && item.name.endsWith("Library") && item.name.contains("Unspecified")
}.each { item ->
item.dependsOn.clear();
}
}
Description
-----------
We have a (command-line) Gradle multi-project build that includes Google Play Services and comprises multiple build flavors, say:
(1) build flavor 'X' depends on library project 'A'
(2) build flavor 'Y' depends on library project 'B'
We often only want to build only one variant - say 'X', but when we try to build a single variant, the dependent library projects of all flavors are built, wasting time during builds. This can take particularly long if the output of 'A' and 'B' are proguarded.
STEPS TO REPRODUCE:
-------------------
1. gradle clean assembleXDebug
EXPECTED RESULTS:
-----------------
Only library project 'A' will be built.
OBSERVED RESULTS:
-----------------
Both library projects 'A' and 'B' are built.
ADDITIONAL INFORMATION:
------------------------
From my research, it appears that for each build variant, a task is generated:
prepare[BuildVariant]Dependencies
which in turn depends on a SINGLE TASK:
prepareComGoogleAndroidGmsPlayServices4030Library
which depends on ALL build variant tasks:
pre[BuildVariant]Build
which causes all dependent libraries for all product flavors to be built.
If I either remove Google Play Services, or clear the task dependencies of 'prepareComGoogleAndroidGmsPlayServices4030Library' using:
prepareComGoogleAndroidGmsPlayServices4030Library.dependsOn.clear()
Then none of the library projects will be built (but the build will probably fail).
It seems to me that the problem is that task dependencies cannot be changed at runtime. Therefore, to avoid building superfluous projects, there should be multiple tasks of the form:
prepareComGoogleAndroidGmsPlayServices4030LibraryFor[BuildVariant]
and then we could have the minimal dependency chain:
prepare[BuildVariant]Dependencies --> prepareComGoogleAndroidGmsPlayServices4030LibraryFor[BuildVariant] --> pre[BuildVariant]Build
ENVIRONMENT:
-------------
Host OS: OS X 10.9.5
SDK tools version: 23.0.5
Gradle version: 2.1
Java version: 1.7.0_67
com.android.tools.build:gradle version: 0.13.3
Eclipse version: N/A
ADT plug-in version: N/A
Platform targeted by your project: 21
Version of the platform running in the emulator: N/A
STEPS TO REPRODUCE:
1.
2.
3.
EXPECTED RESULTS:
OBSERVED RESULTS:
ADDITIONAL INFORMATION:
Attach sample project, etc.
If possible, try to reproduce using ApiDemos.
If the problem is happening in the emulator, consider attaching the output
of "adb bugreport"