Reputation: 419
I was trying to add in app purchase package of flutter. which created the AndroidX migration issue first. Then after migrating I got another error which i have no clue to solve.
I didn't even write any code for in app purchase. Just after adding to pubspec.yaml its causing the problem.
The error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.localbroadcastmanager:localbroadcastmanager' has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath. You should manually set the same version via DependencyResolution
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleDebug failed with exit code 1
pubspec.yaml dependencies
dependencies:
flutter:
sdk: flutter
http:
cloud_firestore:
intl: ^0.15.8
firebase_admob:
firebase_core:
firebase_auth:
firebase_database:
cupertino_icons: ^0.1.2
shared_preferences: 0.5.3+1
emoji_picker:
google_sign_in: ^4.0.1+1
flutter_facebook_login:
firebase_messaging:
image_picker_modern: ^0.4.12+2
firebase_storage:
font_awesome_flutter: ^8.0.1
in_app_purchase: 0.1.0+1
Gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Upvotes: 1
Views: 3076
Reputation: 1547
allprojects {
repositories {
...
}
configurations.all {
resolutionStrategy.force "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0"
}
}
Write resolutionStrategy.force
code in android/build.gradle file.
It will force android to use 1.0.0 version only.
Let me know if you didn't get me.
Upvotes: 0
Reputation: 1547
Original Link: stackoverflow.com/a/56862428/7731547
I fix the error using this answer. You can work around it by adding the following lines next to other subprojects sections in ../android/build.gradle (not ../android/app/build.grade).
Thanks to mklim for the solution.
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.localbroadcastmanager' &&
!details.requested.name.contains('androidx')) {
details.useVersion "1.0.0"
}
}
}
}
my version: firebase_messaging: ^5.0.4
Upvotes: 2
Reputation: 109
carefully follow these steps, had the same error. success! https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
Upvotes: 1