Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed with Invalid <color> for given resource value. error #1714

Open
eduardojmrosa opened this issue May 27, 2024 · 16 comments
Open
Labels

Comments

@eduardojmrosa
Copy link

Hi, my project as cordova 12 with android 12 and i just update the android platform to 13, i change my jdk version to 17 and my gradle to 8.7 but when i run the cordova run android it keep send me this error

Task :app:mergeDebugResources FAILED
C:\Users\eduar.gradle\caches\transforms-4\01bf680c3083cc7cc00592872a745a49\transformed\jetified-play-services-base-18.0.1\res\values\values.xml:4:0: Invalid for given resource value.

Already removed the platform, added it back. Clear the gradle cache and force npm cache clear.

@breautek
Copy link
Contributor

values.xml is not a file that Cordova prepares. So it's likely caused by a plugin that your project has installed.

Might be easy to scan the plugins/ folder to see if anyone of your plugins references values.xml, and if they do; that plugin is most likely the culprit. If you find no references, then it could be coming from a native library being imported by that plugin. In which case I think the best way to determine which plugin is causing the problem is to setup a new project and add each plugin one at a time. Once the project breaks, then you probably found the bad plugin.

When using a hello world app project to test your plugins, Start the build with no plugins installed to rule out that a basic hello world doesn't actually reproduce your issue in your environent. Then proceed to install one plugin at a time and rebuilding after each plugin install.

Let us know what you find.

@breautek breautek added the info-needed / awaiting response Further information is requested label May 27, 2024
@eduardojmrosa
Copy link
Author

I just find out that is the cordova plugin googlemaps givin this error. My app is purely based on this plugin. This error came out in this update. I have a project with android 12 that work pretty well with the same versions. Anything i can do to solve this?

@eduardojmrosa
Copy link
Author

steps i took to find out
-copy my angular project to a new folder
-create new app with cordova
-add android 13

  • install plugin by plugin and run in the android device
  • notice the error with googlemaps
  • remove it and it build sucessfully
    At this point, anything i can do to fix this ? i mean change the plugin(don´t think is possible) or anything can be changed in the cordova-android release to fix ?

@breautek
Copy link
Contributor

I assume you mean https://github.com/mapsplugin/cordova-plugin-googlemaps/tree/master

My workplace utilises this plugin as well, unfortunately the original author no longer maintains it. If you're using the original version, the gmaps the plugin installs by default is quite dated. The plugin also doesn't have values.xml so perhaps it's coming from google maps sdk. My workplace maintains a fork but it also has proprietary code attached so it's not exactly usable as is.

I did run a dev build of cordova-android@13 against my apps awhile back (approx. a year ago...) without issue. Maybe because my apps are using a more recent version of gmaps sdk. You could try applying totalpave/cordova-plugin-googlemaps@f74b8e4 to your own fork to see if it solves your issue.

The original plugin has the ability to set the version via config.xml but it uses the same variable for multiple dependencies, and there is no 18.2.0 version for com.google.android.gms:play-services-location. The linked changeset above separates out the variables and sets the default value to the latest versions at the time of the changeset... the current android gmaps version today is still 18.2.0

@breautek
Copy link
Contributor

For what it's worth I just updated one of my apps to use cordova-android@13 and didn't encounter build issues with google maps plugin. I also reverted those versions back down to what is in the original repo and didn't reproduce the issue either.

If you could package up and share your sample reproduction issue that reproduces your issue I can try taking a deeper look.

@eduardojmrosa
Copy link
Author

Any idea how i can show it to you ? I just create an empty cordova project with cordova 12 and add the android 13, installed this plugin:
https://github.com/mapsplugin/cordova-plugin-googlemaps
and it gives me the above error.
Could you give me your enviroment spec ? maybe my gradle or any config file like config.xml must change to make it work.

@breautek
Copy link
Contributor

Any idea how i can show it to you ? I just create an empty cordova project with cordova 12 and add the android 13, installed this plugin: https://github.com/mapsplugin/cordova-plugin-googlemaps and it gives me the above error. Could you give me your enviroment spec ? maybe my gradle or any config file like config.xml must change to make it work.

Any idea how i can show it to you ? I just create an empty cordova project with cordova 12 and add the android 13, installed this plugin: https://github.com/mapsplugin/cordova-plugin-googlemaps and it gives me the above error. Could you give me your enviroment spec ? maybe my gradle or any config file like config.xml must change to make it work.

I cannot explain why downgrading my version numbers didn't reproduce the issue but using the original authored plugin on a base hello world project does reproduce the issue. Likewise updating the version numbers doesn't correct it either.

This is out of scope of cordova-android but I'll spend a few minutes digging to see if I can find an explanation.

@breautek breautek added bug and removed info-needed / awaiting response Further information is requested labels May 28, 2024
@breautek
Copy link
Contributor

breautek commented May 28, 2024

K so my original statement is wrong, it is a bug with cordova-android introduced by #1700

It looks like the intent is to set the default background color to white (#FFFFFF) but it seems like it ends up defaulting to 0 instead which is an incorrect color value.

Task :app:mergeDebugResources FAILED
C:\Users\eduar.gradle\caches\transforms-4\01bf680c3083cc7cc00592872a745a49\transformed\jetified-play-services-base-18.0.1\res\values\values.xml:4:0: Invalid for given resource value.

Definitely threw me off leading to believe the issue is elsewhere.

If you explicitly set the AndroidWindowSplashScreenBackground preference, it should work around the Invalid color issue.

Do note that the google maps plugin has several other issues and will not build without further changes. But the Invalid for given resource value issue is a bug in cordova-android@13.

Edit: I'm not entirely sure if #1700 is to blame but I don't think I encountered this in my testing in my own apps because I do have AndroidWindowSplashScreenBackground explicitly defined. #1700 just adds in more preferences to make Android match more closely with the iOS platform.

Edit 2: I observe the android platform being set up properly but it turns to 0 if the build errors for some reason. e.g. building with gmaps without supplying an API key causes a build error and when that occurs the value in colors.xml becomes 0, causing the next build to error on an invalid color.

@eduardojmrosa
Copy link
Author

eduardojmrosa commented May 28, 2024

So even fixing this problem i may found problems with the android13 version using the maps plugin ?

@eduardojmrosa
Copy link
Author

Ok, i just tested here, find some errors with permissions and with the transpiling the plugin googlempas to fit in android13 standards, so now the googlemaps plugin will need to be upgraded to fit in the android13 version. Thanks for your help! If you find any repo or method to adapt the current googlemaps plugin to work in this android13 version share with me please :D

@eduardojmrosa
Copy link
Author

eduardojmrosa commented May 28, 2024

Update: This fork https://github.com/TSFArg/cordova-plugin-googlemaps/tree/master have a version that work pretty well with the android 13 version. It only work setting the "AndroidWindowSplashScreenBackground" in the config.xml

Edit: The right link to the maps plugin is this one: https://github.com/marutifh/cordova-plugin-fcm-with-dependecy-updated/tree/master

@GitToTheHub
Copy link

GitToTheHub commented Jun 8, 2024

@eduardojmrosa Thanks for sharing the fork for the fixed google maps plugin. The link points to https://github.com/apache/cordova-android/issues/fork and not https://github.com/TSFArg/cordova-plugin-googlemaps/tree/master. Maybe you can edit this :)

Do you have already good experiences with this fork?

@eduardojmrosa
Copy link
Author

Greetings, i have to update this thread. This isnt the version of the mapsplugins that works well in the New Android version. Ill edit soon.

@rickysut
Copy link

package android.support.annotation does not exist error in my side

@sunco007
Copy link

sunco007 commented Jul 5, 2024

I had this problem and searched in various places until I found what I was looking for.

I created a new project and added the plugins one by one, testing each time. After installing each plugin and testing, there were no errors. So, I copied the config.xml file from the project where I was having issues, and when I tried to compile, it gave me an error.

I deleted groups of lines until I found my problem. The line was the following:

<preference name="SplashScreenBackgroundColor" value="white" />

Changing "white" to "#ffffff" worked for me.

This happened only after updating to Android 13.0.0.

Just for the record I have these plugins:

cordova-plugin-app-version 0.1.14 "AppVersion"
cordova-plugin-customurlscheme 5.0.2 "Custom URL scheme"
cordova-plugin-deeplinks 1.1.1 "Cordova Deeplinks Plugin"
cordova-plugin-device-name 1.3.5 "Device-Name"
cordova-plugin-device 2.1.0 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-fullscreen 1.3.0 "cordova-plugin-fullscreen"
cordova-plugin-in-app-youtube 1.0.0 "Cordova Plugin in app YouTube"
cordova-plugin-inappbrowser 6.0.0 "InAppBrowser"
cordova-plugin-nativestorage 2.3.2 "NativeStorage"
cordova-plugin-safariviewcontroller 2.0.0 "SafariViewController"
cordova-plugin-screen-orientation 3.0.4 "Screen Orientation"
cordova-plugin-splashscreen 6.0.2 "Splashscreen"
cordova-plugin-statusbar 4.0.0 "StatusBar"
cordova-plugin-vibration 3.1.1 "Vibration"
cordova-plugin-x-socialsharing 6.0.4 "SocialSharing"
es6-promise-plugin 4.2.2 "Promise"

@GitToTheHub
Copy link

GitToTheHub commented Oct 10, 2024

@breautek @eduardojmrosa
If found the bug in cordova-plugin-googlemaps. The plugin sets

<preference name="BackgroundColor" value="0"/>

for the config.xml, for the deprecated Crosswalk WebView. It should be #000000, but this would also set the splash screen background color to black. I made a PR which fixes the issue: mapsplugin/cordova-plugin-googlemaps#2941

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants