I created an App using Cordova, then followed the instructions to prepare the App to integrate with the Firebase plugin:
-
创建了密钥库(需要与Firebase集成) .
-
我在Firebase中创建了应用程序的项目,并通知了存储在密钥库中的哈希 .
-
我安装了插件"cordova-plugin-firebase" .
-
将文件google-services.json复制到项目的根文件夹 .
After following the plugin and firebase documentation, I came across this error:
:app:processDebugGoogleServices FAILED FAILURE:构建因异常而失败 . *出了什么问题:任务执行失败':app:processDebugGoogleServices' . >文件google-services.json缺失 . 没有它,Google Services插件无法运行 . 搜索位置:/myAppCordova2/platforms/android/app/src/nullnull/debug/google-services.json /myAppCordova2/platforms/android/app/src/debug/nullnull/google-services.json / myAppCordova2 / platforms / android / app / src / nullnull / google-services.json /myAppCordova2/platforms/android/app/src/debug/google-services.json /myAppCordova2/platforms/android/app/src/nullnullDebug/google-services.json / myAppCordova2 /平台/安卓/应用/谷歌services.json
Solution proposed here in SO: 将google-services.json复制到目录 /platforms/android/app/
,但这会产生另一个错误:
:app:mergeDebugResources FAILED FAILURE:构建因异常而失败 . 出了什么问题:任务执行失败':app:mergeDebugResources' . [string / google_app_id] /myAppCordova2/platforms/android/app/src/main/res/values/strings.xml [string / google_app_id] / myAppCordova2 / platforms / android / app / build / generated / res / google-services / debug /values/values.xml:错误:重复资源[string / google_api_key] /myAppCordova2/platforms/android/app/src/main/res/values/strings.xml [string / google_api_key] / myAppCordova2 / platforms / android / app / build / generated / res / google-services / debug / values / values.xml:错误:资源重复
PS: 我尝试了SO中提出的几个修正案,没有一个解决了我的问题,任何人都可以帮助我吗?
1 回答
I found a solution to problem:
这里提供了与我所遵循的相似的指令(并且导致了问题),尽管依赖项的版本有点过时了:
在我的案例中导致问题的原因是在Firebase的App创建页面上按照这些说明进行操作,并在项目和模块的
build.gradle
文件中添加依赖项,如下所示:添加项目build.gradle
/project/platforms/android/build.gradle
:并添加模块build.gradle
/project/platforms/android/app/build.gradle
:Solution:
我找到的解决方案是评论注释
// Firebase
前面的行:文件:
/project/platforms/android/build.gradle
:文件:
/project/platforms/android/app/build.gradle
:完成这些步骤后,一切正常,我能够毫无问题地运行
$ cordova build android
.Suggestion: 如果发生任何其他错误,请尝试删除插件和平台,然后重新创建它们: