在尝试使用Android Studio 3.5.2,Android SDK 28和cordova-plugin-firebase编译以前可以使用的Android应用程序时,我在这里读到我应该安装cordova-plugin-firebasex作为可以在Androidx上运行的并且当前维护的fork。
第一个问题,删除cordova-plugin-firebase,我解决如下:
您无法使用常规方法删除此插件
cordova plugin remove cordova.plugin.firebase --save
由于plugin.xml文件中的错误,这将删除整个/ main目录:
<resource-file src="src/android/google-services.json" target="."/>
并且卸载失败。
我从XML文件中删除了该行,然后再次尝试通过cli删除插件。
这导致出现此消息:
不支持使用“ requireCordovaModule”加载非cordova模块“ xcode”。而是,将此模块添加到您的依赖项中,并使用常规的“ require”进行加载。
按照此处的说明,我编辑了plugins / cordova-plugin-firebase / scripts / ios / helper.js
我加了
var xcode = require("xcode");
在文件中,然后取出两个实例中
var xcode = context.requireCordovaModule("xcode");
再次尝试删除插件并得到
从ios上卸载cordova-plugin-firebase从osx上卸载cordova-plugin-firebase删除“ cordova-plugin-firebase”找不到插件“ cordova-plugin-google-analytics”的plugin.xml。
我删除并重新安装了Google Analytics(分析)插件,然后成功卸载了Firebase插件。
然后,我添加了Firebasex和用于播放服务和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。
我曾尝试在整个目录中添加“:15.0.1”和“ @ 15.0.1”,但找不到罪魁祸首。我尝试卸载具有以下版本说明符的重新安装插件:
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 \
这会引发新的依赖项不匹配:
无法确定任务':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-地下室版本为17.0.0。
因此,我还尝试将所有库推到其最新版本,从而为该应用生成以下build.gradle:
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.gms:play-services-flags:15.0.1-> com.google.android.gms:play-services-basement @ [15.0.1],但play-services-basement版本是17.0.0。
我对库依赖仍然不屑一顾(尽管最近三天我一直在爬升学习曲线,直到我需要氧气)–我如何在这里找到罪魁祸首,以及为什么应该使用这些插件为我做失败?
我设法找到了一个可以正常工作的APK的解决方案。然而,
在更改代码后,我不能再简单地重新构建应用程序,而必须删除平台,再次添加它并遵循以下步骤。
我必须删除Firebase消息传递功能(
无论如何我都不会使用它)
但是,如果这可能对花了太多时间试图使Firebase正常工作的其他人有用,这是我的过程:
如果已安装,请删除Firebasex插件和cordova-android-play-services-gradle-release插件以及cordova-android-firebase-gradle-release。(如果您安装了FIREBASE而不是FIREBASEX,请参阅上面的问题以获取删除方法。)然后:
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。
它会警告您升级gradle版本。不要这样
现在,同步将成功,但是运行将失败,并显示错误消息:
安装未成功。无法安装该应用程序:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED由于以下原因导致安装失败:'null'重试
在您的AndroidManfiest.xml中,向应用程序标签添加:忽略GoogleAppIndexingWarning:
<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" />
如果此时运行该应用程序,您将收到以下消息:
java.lang.RuntimeException:清单合并失败:来自AndroidManifest.xml:31:66-90的属性meta-data#com.google.android.gms.version@value value =(59056789)也出现在[com.google。 android.gms:play-services-basement:17.0.0] AndroidManifest.xml:25:13-66 value =(@ integer / google_play_services_version)。建议:在AndroidManifest.xml:31:9-94的元素上添加'tools:replace =“ android:value”'以进行覆盖。
添加到Manifest.xml:
<meta-data android:name="com.google.android.gms.version" android:value="12451000" tools:replace="android:value" />
该应用程序现在可以正确编译,运行和报告Firebase事件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句