我添加了cordova-plugin-firebase后,构建失败。每次我得到不同的错误。 我注意到该插件也在更改我的google-service.json。 我得到的最大错误是:
Execution failed for task ':app:fabricGenerateResourcesDebug'.
> Crashlytics Developer Tools error.
app:fabricGenerateResourcesDebug FAILED
ERROR - Crashlytics Developer Tools error.
java.lang.IllegalArgumentException: Crashlytics found an invalid API key:
null.
Check the Crashlytics plugin to make sure that the application has been
added successfully!
Contact support@fabric.io for assistance.
我不知道为什么需要此工具,以及与此相关的io fabric。 我尚未从io fabric安装或迁移任何东西。 这是我的package.json依赖项:
"@angular/animations": "^8.1.2",
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@ionic-native/core": "^5.0.0",
"@ionic-native/fabric": "^5.12.0",
"@ionic-native/firebase": "^5.0.0",
"@ionic-native/social-sharing": "^5.11.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^4.1.0",
"@ionic/storage": "^2.2.0",
"angularfire2": "^5.2.1",
"cordova-android": "^8.0.0",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-plugin-firebase": "^2.0.5",
"cordova-plugin-x-socialsharing": "^5.4.7",
"cordova-sqlite-storage": "^3.2.1",
"cordova-support-google-services": "^1.3.1",
"core-js": "^2.5.4",
"es6-promise-plugin": "^4.2.2",
"firebase": "^6.3.1",
*我的应用程序级构建gradle依赖项:
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'com.google.firebase:firebase-core:17.0.0'
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
implementation "com.google.android.gms:play-services-tagmanager:+"
implementation "com.google.firebase:firebase-core:+"
implementation "com.google.firebase:firebase-messaging:+"
implementation "com.google.firebase:firebase-config:+"
implementation "com.google.firebase:firebase-perf:+"
implementation "androidx.annotation:annotation:1.0.0"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
// SUB-PROJECT DEPENDENCIES END
}
*我的项目级别的构建级别依赖项:
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.1.0' // google-services
dependency from cordova-plugin-firebase
classpath 'io.fabric.tools:gradle:1.25.4' // fabric dependency from
cordova-plugin-firebase
}
项目属性:
target=android-28
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-android-firebase-gradle-release/promocat-
cordova-android-firebase-gradle-release.gradle
cordova.gradle.include.2=cordova-plugin-firebase/promocat-build.gradle
cordova.system.library.1=com.google.android.gms:play-services-tagmanager:+
cordova.system.library.2=com.google.firebase:firebase-core:+
cordova.system.library.3=com.google.firebase:firebase-messaging:+
cordova.system.library.4=com.google.firebase:firebase-config:+
cordova.system.library.5=com.google.firebase:firebase-perf:+
cordova.system.library.6=androidx.annotation:annotation:1.0.0
cordova.system.library.7=androidx.legacy:legacy-support-v4:1.0.0
cordova.gradle.include.3=phonegap-plugin-multidex/promocat-multidex.gradle
构建后,该插件会将我从firebase下载的google-service.json更改为此:
"project_info": {
"project_number": "123",
"firebase_url": "https://cordova-plugin-firebase.firebaseio.com",
"project_id": "cordova-plugin-firebase",
"storage_bucket": "cordova-plugin-firebase.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:123:android:123",
"android_client_info": {
"package_name": "com.github.cordova_plugin_firebase"
}
},
"oauth_client": [
{
"client_id": "123.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "123"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
答案 0 :(得分:0)
显然,原始的cordova-plugin-firebase插件存在问题。 我安装了另一个与此类似的插件,问题已解决。
以下是新插件的链接: https://github.com/dpa99c/cordova-plugin-firebasex#readme