S_R
S_R

Reputation: 1998

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. I'm receiving the following error whenever I try to build

Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']

For input string: "11+"

I've had a look on stack overflow and the fix is to remove the + from the build.gradle dependencies. 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.

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!?

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?

Upvotes: 0

Views: 451

Answers (1)

DaveAlden
DaveAlden

Reputation: 30366

In a Cordova Android project, any files (including build.gradle) inside the platforms/android/ directory are considered volatile and should not be manually edited. In fact if you run cordova platform rm android the entire platforms/android/ directory will be deleted. 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. So whatever solution you choose needs to work with the Cordova build lifecycle.

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:

Upvotes: 3

Related Questions