我按照Add Firebase to your Android project中的说明配置了我(弹出)的本机项目。 当我执行
react-native run-android
或者我在Android Studio中构建项目,但出现错误:
任务:react-native-firebase:processDebugGoogleServices FAILED 解析json文件:/ Users /.../ myapp / node_modules / react-native-firebase / android / google-services.json
失败:构建失败,并出现异常。
未找到与包名称“ io.invertase.firebase”匹配的客户端
这是我对项目 build.gradle 的补充:
dependencies {
implementation project(':react-native-firebase')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.firebase:firebase-core:16.0.4"
implementation 'com.google.firebase:firebase-firestore:17.1.1'
implementation 'com.google.firebase:firebase-auth:16.0.4'
}
...
apply plugin: 'com.google.gms.google-services'
这是应用程序 build.gradle :
buildscript {
ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries)
// is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "https://jitpack.io"
}
}
}
我还将 ... / myapp / node_modules / react-native-firebase / android / build.gradle 中的版本更新为:
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
api "com.facebook.react:react-native:+" // From node_modules
api "com.android.support:support-v4:$supportVersion"
// Firebase SDKs
compileOnly('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
transitive = true
}
//noinspection GradleCompatible
compileOnly "com.google.firebase:firebase-core:16.0.4"
compileOnly "com.google.android.gms:play-services-base:16.0.1"
compileOnly "com.google.firebase:firebase-ads:16.0.1"
compileOnly "com.google.firebase:firebase-auth:16.0.4"
compileOnly "com.google.firebase:firebase-config:16.0.1"
compileOnly "com.google.firebase:firebase-crash:16.2.1"
compileOnly "com.google.firebase:firebase-database:16.0.3"
compileOnly "com.google.firebase:firebase-firestore:17.1.1"
compileOnly "com.google.firebase:firebase-functions:16.1.1"
compileOnly "com.google.firebase:firebase-invites:16.0.4"
compileOnly "com.google.firebase:firebase-storage:16.0.3"
compileOnly "com.google.firebase:firebase-messaging:17.3.3"
compileOnly "com.google.firebase:firebase-perf:16.1.2"
compileOnly 'me.leolin:ShortcutBadger:1.1.21@aar'
implementation 'com.google.firebase:firebase-firestore:17.1.1'
implementation 'com.google.firebase:firebase-auth:16.0.4'
}
我在Android Studio中使用了Tools-> Firebase,并使用了 Connect to Firebase 和将Firebase身份验证添加到您的应用(或添加Firebase firestorm ...)按钮,然后为这些库添加不同的版本,如下所示:
// implementation 'com.google.firebase:firebase-firestore:17.1.1'
// implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.firebase:firebase-firestore:17.0.1:15.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
(我在项目和react-native-firebase build.gradle文件中都注释掉了我的原始条目)。但是仍然是相同的错误。
有什么建议吗? 谢谢!