>我目前正在尝试将Firebase消息集成到我的项目中,我已经建立了一个Firebase项目并成功导入了我需要的所有其他依赖项(崩溃,firestore等... 但是,当我将 Firebase 消息传递依赖项添加到我的pubspec.yaml
时,我在构建时出现错误。我正在使用最新版本的firebase_messaging
以及最新版本的谷歌服务。
错误:
Plugin project: firebase_core_web not found. Please update settings.gradle.
Invalid depfile: C:UsersOwnerAndroidStudioProjectsswitcheroo_ios.dart_toolflutter_buildd71b8b11f916190e0bd095c78ccf0a69kernel_snapshot.d
Invalid depfile: C:UsersOwnerAndroidStudioProjectsswitcheroo_ios.dart_toolflutter_buildd71b8b11f916190e0bd095c78ccf0a69kernel_snapshot.d
AGPBI: {"kind":"error","text":"Type com.google.firebase.iid.zzbb is referenced as an interface from `com.google.firebase.messaging.zzf`.","sources":[{}],"tool":"D8"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform artifact 'firebase-messaging.aar (com.google.firebase:firebase-messaging:20.0.1)' to match attributes {artifactType=android-dex, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21}.
> Execution failed for DexingWithClasspathTransform: C:UsersOwner.gradlecachestransforms-2files-2.1ac2c922e894bed89371853ed7d90bb4ejetified-firebase-messaging-20.0.1jarsclasses.jar.
> Error while dexing.
应用分级:
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 plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.barbecu.switcherooIOS"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-crashlytics:17.0.1'
}
格拉德尔项目:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.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
}
尝试添加
implementation 'com.google.firebase:firebase-messaging:20.0.1'
内部依赖项
只需尝试添加R与每个平台明确相关的依赖项,如上所示在Android中
对于 iOS(我不确定 iOS 生态系统(,但添加它可能会有所帮助
pod 'Firebase/Messaging'
1.- 在build.gradle(项目级别(中使用:
classpath 'com.google.gms:google-services:4.3.3'//Google Services plugin
2.- 在build.gradle(应用程序级别(中使用:
minSdkVersion 21
3.- 将 settings.gradle 内容替换为此处提供的解决方案:
插件项目 :firebase_core_web 未找到