【发布时间】:2018-11-11 17:10:49
【问题描述】:
我想在我的 Flutter 应用程序中实现 Firebase Cloud Messaging,我开始实现 Android 部分。我像在 Firebase 文档中一样添加了依赖项,但是现在我在构建我的应用程序时遇到了 gradle 错误:
The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.0.0,16.0.0]], but resolves to 15.1.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
我对 gradle 一点经验都没有,所以我希望能得到一些帮助^^
这里是 app/build.gradle
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.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.leodr.pguapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
}
apply plugin: 'com.google.gms.google-services'
这里是项目 build.gradle(如果需要):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.0'
}
}
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
}
【问题讨论】:
-
我能看到的第一件事是你的 app/build.gradle 丢失了
compile 'com.google.firebase:firebase-core:16.0.0' -
当我添加它时抛出另一个错误^^:
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies. -
classpath 'com.google.gms:google-services:4.0.0'到classpath 'com.google.gms:google-services:4.0.1'?我可能应该做一个新项目来复制这个问题。 -
不幸的是,这并没有解决任何错误:(
-
这听起来像是依赖冲突,但不确定是什么。稍后我会回到这个并尝试这个项目。
标签: firebase gradle dart firebase-cloud-messaging flutter