Cordova Firebase插件故障 [英] Cordova firebase plugin failures
问题描述
在尝试使用Android Studio 3.5.2,Android SDK 28和cordova-plugin-firebase编译以前可以使用的Android应用程序,我应该安装cordova-plugin-firebasex作为可以在Androidx上运行的工作且当前维护的fork 。
In attempting to compile a previously working Android app with Android Studio 3.5.2, Android SDK 28 and the cordova-plugin-firebase I read here that I should install cordova-plugin-firebasex as a working and currently maintained fork that works on Androidx.
第一个问题,删除了cordova-plugin-firebase,我的解决方法如下:
First issue, removing the cordova-plugin-firebase, I resolved as follows:
您无法删除此问题使用常规方法的插件
You cannot remove this plugin with the conventional method
cordova plugin remove cordova.plugin.firebase --save
由于 plugin.xml文件中的错误:
<resource-file src="src/android/google-services.json" target="."/>
,卸载失败。
I从XML文件中删除了该行,然后再次尝试通过cli删除插件。
I removed that line from the XML file and again attempted to remove the plugin via the cli.
这将导致以下消息:
使用 requireCordovaModule加载非-cordova模块 xcode不受支持。取而代之的是,将此模块添加到您的依赖项中,并使用常规的 require加载它。
Using "requireCordovaModule" to load non-cordova module "xcode" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
在此处的说明我编辑了plugins / cordova-plugin-firebase / scripts / ios / helper.js
Following instructions here I edited plugins/cordova-plugin-firebase/scripts/ios/helper.js
我添加了
var xcode = require("xcode");
位于文件顶部,并删除两个实例
at the top of the file and remove two instances of
var xcode = context.requireCordovaModule("xcode");
再次尝试删除插件并得到
Again attempt removal of plugin and got
从ios上卸载cordova-plugin-firebase
从osx上卸载cordova-plugin-firebase删除
cordova-plugin-firebase找不到插件$ b $的plugin.xml b cordova-plugin-google-analytics。
Uninstalling cordova-plugin-firebase from ios Uninstalling cordova-plugin-firebase from osx Removing "cordova-plugin-firebase" Cannot find plugin.xml for plugin "cordova-plugin-google-analytics".
我删除并重新安装了Google Analytics(分析)插件,然后成功卸载了Firebase插件。
I removed and reinstalled the google analytics plugin, and the firebase plugin successfully uninstalled.
然后我添加了Firebasex以及用于播放服务和Firebase的推荐版本的牧马人:
I've then added Firebasex and the recommended version wranglers for play services and firebase:
cordova plugin add cordova-plugin-firebasex
cordova plugin add cordova-android-play-services-gradle-release
cordova-android-firebase-gradle-release
我收到以下编译错误:
无法确定任务':app:compileReleaseJavaWithJavac'的依赖关系。
在项目应用中,已解析的Google Play服务库依赖项依赖于另一个版本的
(例如 [15.0。
1],但未解析为该版本)
库显示的行为将是未知的
依赖项失败:
com.google.android.gms:play-services-flags:15.0.1-> com.google.android。 gms:play-services-basement @ [
15.0.1],但play-services-basement版本为17.0.0。
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'. In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0. 1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown. Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement@[ 15.0.1], but play-services-basement version was 17.0.0.
我尝试在整个目录中添加':15.0.1'和'@ 15.0.1'的内容,但找不到罪魁祸首。我尝试卸载具有以下版本说明符的重新安装插件:
I've tried grepping my entire directory for ':15.0.1' and '@15.0.1' but I cannot find the culprit. I tried uninstalling a reinstalling the plugin with the following version specifiers:
cordova plugin add cordova-plugin-firebasex \
--variable ANDROID_PLAY_SERVICES_TAGMANAGER_VERSION=17.0.0 \
--variable ANDROID_FIREBASE_CORE_VERSION=17.0.0 \
--variable ANDROID_FIREBASE_MESSAGING_VERSION=19.0.0 \
--variable ANDROID_FIREBASE_CONFIG_VERSION=18.0.0 \
--variable ANDROID_FIREBASE_PERF_VERSION=18.0.0 \
--variable ANDROID_FIREBASE_AUTH_VERSION=18.0.0 \
--variable ANDROID_CRASHLYTICS_VERSION=2.10.1 \
--variable ANDROID_CRASHLYTICS_NDK_VERSION=2.1.0 \
并抛出新的依赖项不匹配:
and that spits up a new dependency mismatch:
无法确定任务':app:preReleaseBuild'的依赖关系。
Could not determine the dependencies of task ':app:preReleaseBuild'.
在项目应用中,已解析的Google Play服务库依赖项依赖于另一个版本(例如, [11.0。1],但不是
被解析为该版本。图书馆展示的行为
是未知的。
依赖关系失败:com.google.android.gms:play-services-tagmanager-v4-impl:11.0.1->
com.google.android.gms:play-servic es-basement @ [ 11.0.1],但
play-services-basement版本为17.0.0。
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[11.0. 1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown. Dependency failing: com.google.android.gms:play-services-tagmanager-v4-impl:11.0.1 -> com.google.android.gms:play-servic es-basement@[11.0.1], but play-services-basement version was 17.0.0.
所以我也尝试将所有库推到最新版本,从而为应用程序生成以下
build.gradle:
So I've also tried pushing all libraries to their most recent versions, resulting in the following build.gradle for the app:
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-identity:17.0.0'
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-config:19.0.3'
implementation 'com.google.firebase:firebase-perf:19.0.1'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation "com.google.android.gms:play-services-tagmanager:17.0.0"
implementation "com.google.firebase:firebase-core:17.2.1"
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-config:19.0.3'
implementation 'com.google.firebase:firebase-perf:19.0.1'
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation "com.crashlytics.sdk.android:crashlytics:2.10.1"
implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.1.1'
implementation "me.leolin:ShortcutBadger:1.1.22"
// SUB-PROJECT DEPENDENCIES END }
哪个让我吐槽回到
依赖项失败:com.google.android.gm s:play-services-flags:15.0.1
-> com.google.android.gms:play-services-basement @ [
15.0.1],但play-services-basement版本为17.0 .0。
Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement@[ 15.0.1], but play-services-basement version was 17.0.0.
我对图书馆的依存性仍然不屑一顾(尽管我在过去三个学习中一直在努力学习)天到我需要氧气的地步)-我如何在这里找到罪魁祸首,为什么应该为我这样做的插件却失败了?
I'm still a noob at Library dependencies (though I've been hiking up the learning curve for the last three days to the point I need oxygen) -- how can I find the culprit here, and why are the plugins that are supposed to do that for me failing?
推荐答案
我设法找到了一个构建有效APK的解决方案。但是,
I've managed to arrive at a solution which builds a working APK. HOWEVER,
-
代码更改后,我不能再简单地重新构建应用程序,而必须删除平台添加的
再次执行以下步骤。
I can no longer simply rebuild the app after code changes, but have to remove the platform add it again and follow the following steps.
我必须删除Firebase消息传递功能(无论如何我都不
使用它)
I have had to remove the Firebase messaging functionality (I don't
use it anyway)
但是,如果这可能对花了太多时间试图使Firebase正常工作的其他人有用,这是我的流程:
But in case this may be of service to someone else who has spent far too many hours trying to get Firebase functional, here's my process:
如果已安装Firebasex插件和cordova-android-play-services-gradle-release插件以及cordova-android-firebase-gradle-release,请删除它们。 (如果您安装了FIREBASE而不是FIREBASEX,请参阅上面的问题以获取删除方法。)然后:
Remove the Firebasex plugin and the cordova-android-play-services-gradle-release plugin and the cordova-android-firebase-gradle-release if they are installed. (If you have FIREBASE and not FIREBASEX installed, see my question above for removal method.) Then:
cordova plugin add cordova-plugin-firebasex
cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=17.0.0
cordova plugin add cordova-android-firebase-gradle-release --variable FIREBASE_VERSION=17.0.0
cordova platform rm android
cordova platform add android
cordova build android
rm platforms/android/app/libs/google-play-services.jar
导入Android Studio。
Import into Android Studio.
它会警告您升级gradle版本。不要做
It will warn you upgrade your gradle release. Don’t do it.
同步现在可以成功,但是运行将失败,并显示错误消息:
The Sync will now succeed, but the run will fail with error message:
安装未成功。无法安装该应用程序:
INSTALL_PARSE_FAILED_MANIFEST_MALFORMED由于以下原因导致安装失败:
'null'重试
Installation did not succeed. The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED Installation failed due to: 'null' Retry
在您的AndroidManfiest.xml,添加:忽略GoogleAppIndexingWarning到应用程序标签:
In your AndroidManfiest.xml, add: ignore GoogleAppIndexingWarning to the application tag:
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning">
删除:
<service android:name="org.apache.cordova.firebase.FirebasePluginMessagingService"
android:permission="TODO">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
删除:
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/accent" />
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id" />
如果此时运行该应用程序,则会收到类似以下消息:
If you run the app at this point, you'll get a message like:
java.lang.RuntimeException:清单合并失败:属性
meta-data#com.google.android.gms.version@value value = (59056789)来自
AndroidManifest.xml:31:66-90也位于
[com.google.android.gms:play-services-basement:17.0.0]
AndroidManifest中。 xml:25:13-66
value =(@ integer / google_play_services_version)。建议:将
'tools:replace = android:value'添加到
AndroidManifest.xml:31:9-94处的元素以进行覆盖。
java.lang.RuntimeException: Manifest merger failed : Attribute meta-data#com.google.android.gms.version@value value=(59056789) from AndroidManifest.xml:31:66-90 is also present at [com.google.android.gms:play-services-basement:17.0.0] AndroidManifest.xml:25:13-66 value=(@integer/google_play_services_version). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:31:9-94 to override.
添加到Manifest.xml:
Add to Manifest.xml:
<meta-data android:name="com.google.android.gms.version" android:value="12451000" tools:replace="android:value" />
应用程序现在可以正确编译,运行并报告Firebase事件。
The app now compiles, runs, and reports Firebase events properly.
这篇关于Cordova Firebase插件故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!