我试图添加Flutter的应用购买包。首先造成了AndroidX迁移问题。然后,在迁移之后,我又遇到了另一个我无法解决的错误。
我什至没有为应用内购买编写任何代码。刚添加到pubspec.yaml后,就会引起问题。
错误
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:
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
答案 0 :(得分:1)
原始链接:stackoverflow.com/a/56862428/7731547
我使用此答案解决了错误。您可以通过在../android/build.gradle(不是../android/app/build.grade)中其他子项目部分旁边添加以下行来解决此问题。
感谢mklim解决方案。
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.localbroadcastmanager' &&
!details.requested.name.contains('androidx')) {
details.useVersion "1.0.0"
}
}
}
}
我的版本:firebase_messaging:^ 5.0.4
答案 1 :(得分:0)
仔细执行以下步骤,出现相同的错误。成功! https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
答案 2 :(得分:0)
allprojects {
repositories {
...
}
configurations.all {
resolutionStrategy.force "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0"
}
}
在android / build.gradle文件中编写resolutionStrategy.force
代码。
它将强制android仅使用1.0.0版本。
让我知道你是否没有得到我。