Reputation: 2562
I am attempting to update my app for Android O, and in doing so need to update to support library 26.
My compileSdkVersion is 26, targetSdkVersion 26, buildToolsVersion 26.0.1, and support library version is 26.0.1, and play services/firebase messaging is 11.0.4. I'm using Android Studio 3.0 b2, and the android gradle plugin 3.0.0-beta2. It appears that this version is much more sensitive to support library conflicts.
I've had to manually exclude the support dependencies to resolve conflicts since play services and firebase link against older versions of the support libraries:
implementation("com.google.android.gms:play-services-auth:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.android.gms:play-services-identity:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.android.gms:play-services-base:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.android.gms:play-services-analytics:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.firebase:firebase-messaging:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.firebase:firebase-analytics:$playServicesVersion",{
exclude group: 'com.android.support'
})
This fixes all my dependency conflicts except one.
Google Play Services/Firebase requires the use of a google-services gradle plugin to parse the generated .json file and include the necessary keys/secrets in the app. My build.grade has a buildscript block like so:
buildscript {
repositories {
maven { url "https://maven.google.com" }
jcenter()
}
dependencies {
classpath "com.google.gms:google-services:3.1.0"
}
}
and at the end of the script, I apply the plugin. With the apply and classpath commented out, everything compiles properly. However it appears that the google-services 3.1.0 adds a dependency on support library version 25.2.0, and I haven't been able to figure out how to override it. The message is:
- What went wrong: Execution failed for task ':app:preDevelopmentDebugBuild'.
Android dependency 'com.android.support:support-v4' has different version for the compile (25.2.0) and runtime (26.0.1) classpath. You should manually set the same version via DependencyResolution
Note that I can't even downgrade to support library 25.4.0, as I get the same error (just replace 26.0.1 in the message above with 25.4.0). The only version that works is 25.2.0
Running ./gradlew app:dependencies
with the classpath dependency included, gives me this:
compile - Compile dependencies for 'main' sources (deprecated: use 'implementation' instead).
\--- com.google.firebase:firebase-core:11.0.4
\--- com.google.firebase:firebase-analytics:[11.0.4] -> 11.0.4
+--- com.google.firebase:firebase-analytics-impl:[11.0.4] -> 11.0.4
| +--- com.google.android.gms:play-services-basement:[11.0.4] -> 11.0.4
| | \--- com.android.support:support-v4:25.2.0
| | +--- com.android.support:support-compat:25.2.0
| | | \--- com.android.support:support-annotations:25.2.0
| | +--- com.android.support:support-media-compat:25.2.0
| | | +--- com.android.support:support-annotations:25.2.0
| | | \--- com.android.support:support-compat:25.2.0 (*)
| | +--- com.android.support:support-core-utils:25.2.0
| | | +--- com.android.support:support-annotations:25.2.0
| | | \--- com.android.support:support-compat:25.2.0 (*)
| | +--- com.android.support:support-core-ui:25.2.0
| | | +--- com.android.support:support-annotations:25.2.0
| | | \--- com.android.support:support-compat:25.2.0 (*)
| | \--- com.android.support:support-fragment:25.2.0
| | +--- com.android.support:support-compat:25.2.0 (*)
| | +--- com.android.support:support-media-compat:25.2.0 (*)
| | +--- com.android.support:support-core-ui:25.2.0 (*)
| | \--- com.android.support:support-core-utils:25.2.0 (*)
| +--- com.google.firebase:firebase-iid:[11.0.4] -> 11.0.4
| | +--- com.google.android.gms:play-services-basement:[11.0.4] -> 11.0.4 (*)
| | \--- com.google.firebase:firebase-common:[11.0.4] -> 11.0.4
| | +--- com.google.android.gms:play-services-basement:[11.0.4] -> 11.0.4 (*)
| | \--- com.google.android.gms:play-services-tasks:[11.0.4] -> 11.0.4
| | \--- com.google.android.gms:play-services-basement:[11.0.4] -> 11.0.4 (*)
| +--- com.google.firebase:firebase-common:[11.0.4] -> 11.0.4 (*)
| \--- com.google.android.gms:play-services-tasks:[11.0.4] -> 11.0.4 (*)
+--- com.google.android.gms:play-services-basement:[11.0.4] -> 11.0.4 (*)
\--- com.google.firebase:firebase-common:[11.0.4] -> 11.0.4 (*)
Upvotes: 4
Views: 8412
Reputation: 126734
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.1'
}
}
}
}
Like this your support libraries should all compile with the same version. Just add the snippet in your module level Gradle build script to the dependencies.
Upvotes: 5
Reputation: 2562
It appears that the issue actually has to do with dependencies included via sub-modules. The support libraries were being included via a common sub-module, e.g.:
implementation project(':common')
I also attempted:
implementation(project(':common'),{transitive = true})
But this made no difference.
The only thing that worked was to directly include the support libraries in my top-level build.gradle
Upvotes: 0