Fixing Dependency Conflict In OneSignal Android
Whilst following OneSignal’s setup guide for their Android SDK, everything went smoothly until attempting to run the build past our CI (continuous integration) server, CircleCI. I’ve encountered various issues when using custom build flavours with OneSignal before, and expect that was the cause of this issue too.
The build failed, due to the following exception:
Execution failed for task ':app:preCustomflavourQaAndroidTestBuild'.
> Conflict with dependency 'com.google.firebase:firebase-messaging' in project ':app'. Resolved versions for app (17.0.0) and test app (12.0.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
As Firebase messaging was not used in any modules inside the project, only by OneSignal, the conflict was a little confusing. Was it… conflicting with itself!? Regardless, the solution was relatively straightforward, simply forcing Firebase Messaging to always resolve to the correct version (17.0.0) fixed the test build.
Inside the app-level build.gradle
, add:
configurations.all {
resolutionStrategy {
force "com.google.firebase:firebase-messaging:17.0.0"
}
}
This change fixed the test build, and our CI was back to a lovely sea of green success messages!