简体   繁体   English

停止Cordova CLI恢复build.gradle

[英]Stop cordova cli reverting build.gradle

This one sounds a little bit weird! 这听起来有点不可思议!

I'm building an app with cordova, and I'm trying to implement firebase. 我正在使用cordova构建应用程序,并且正在尝试实现Firebase。 I'm receiving the following error whenever I try to build 每当我尝试构建时,我都会收到以下错误

Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin'] 无法应用插件[类'com.google.gms.googleservices.GoogleServicesPlugin']

For input string: "11+" 对于输入字符串:“ 11+”

I've had a look on stack overflow and the fix is to remove the + from the build.gradle dependencies. 我看过堆栈溢出,解决方法是从build.gradle依赖项中删除+ I remove it and then build through android studio which works great, but whenever I try to build via cli using cordova build android , it reverts the build.gradle and adds the + back on and the build fails. 我删除了它,然后通过运行良好的android studio进行了构建,但是每当我尝试使用cordova build android通过cli进行cordova build android ,它都会还原build.gradle并添加+ ,然后构建失败。

I need able to build via Cordova build android because if I don't build the application again via the cli, my changes to the code are not recognized!? 我需要能够通过Cordova build android进行构建,因为如果不通过cli再次构建应用程序,则无法识别对代码的更改!

It's almost like every time I make a change, I have to run the build for the code changes to be recognized. 几乎就像我每次进行更改一样,我都必须运行构建以使代码更改得以识别。

How can I build via cordova build android without it adding the + back into the build.grade ? 我如何通过cordova build android进行cordova build android而无需将+添加回build.grade

In a Cordova Android project, any files (including build.gradle ) inside the platforms/android/ directory are considered volatile and should not be manually edited. 在Cordova Android项目中, platforms/android/目录中的任何文件(包括build.gradle )都被视为易失性的,不应手动编辑。 In fact if you run cordova platform rm android the entire platforms/android/ directory will be deleted. 实际上,如果您运行cordova platform rm android ,则会删除整个platforms/android/目录。 The build.gradle file is dynamically recreated every time the cordova prepare lifecycle event takes place using a template from cordova-android and then is dynamically modified as Cordova plugins, etc. are processed. build.gradle使用cordova-android的模板进行一次cordova prepare生命周期事件发生时,都会动态重新创建build.gradle文件,然后在处理Cordova插件等时对其进行动态修改。 So whatever solution you choose needs to work with the Cordova build lifecycle. 因此,无论选择哪种解决方案,都需要使用Cordova构建生命周期。

One option to is to use 3rd-party plugins to override the library versions specified by other Cordova plugins in order to align them and prevent such build failures, for example: 一种选择是使用第三方插件来覆盖其他Cordova插件指定的库版本,以便对齐它们并防止此类构建失败,例如:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM