flutter - Android 依赖在编译和运行时有不同的版本:runing FCM dependency
问题描述
很长时间以来我一直在尝试使用 FCM,但我遇到了 android X 的问题,我将颤振升级到最新版本,这里是颤振医生:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.17134.885], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] Android Studio (version 3.2)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.36.1)
[√] Connected device (1 available
然后我用这条线用 androidX 创建了一个新项目:
flutter create --androidx project_name
然后我在 yaml 文件中添加了 FCM 依赖项:
firebase_messaging: ^5.1.2
并且我在不添加任何其他内容的情况下运行该项目以确保该包不会像以前一样出现问题,但不幸的是它确实如此。这是错误:
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
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 3.5s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Gradle task assembleDebug failed with exit code 1
这是 build.gradle/app :
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.cantina_summer"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
这里是 build.gradle/android:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
任何帮助将不胜感激,
解决方案
代替
classpath 'com.android.tools.build:gradle:3.2.1'
和
classpath 'com.android.tools.build:gradle:3.3.0'
推荐阅读
- javascript - 使用 reactjs 前端将数据插入到 nodejs 和 mongodb 后端时出现问题
- python - 通过列表项循环访问前一项的优雅方式
- javascript - TypeScript 'number' 不可分配给 0 | 10 | 20 即使数字为 0
- javascript - 具有数千个可观察对象的 Knockout.js 表单对浏览器性能的影响
- c# - 如何模拟模拟的 IQueryable 的 .Where() 扩展
使用 NSubstitite - python - 无法从定义中调用 StringVar(根据下拉菜单保存到 .csv 中的特定行)
- cassandra - cqlsh -e“复制表”永远挂起
- python - gspread 列的选择列表
- c++ - 没有运算符匹配这些操作数;操作数类型为:std::istream >> const char [5]
- html - spring如何用thymeleaf添加静态资源