-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
colors.xml resource causes platform error "Cannot set properties of null (setting 'text')" #1728
Comments
colors.xml is used by cordova framework. By providing your own resource file you're overwriting what cordova has prepared, which is missing values that cordova expects leading to your error. It will probably be best to choose a different filename. |
Ok tx for the reply. I'm not sure it makes sense... I wanted to set my own color resource for use as a background for Adaptive Icons for Android. I've since used a Drawable Vector XML instead but it would good understand why the docs specifically specify using that filename if that's not correct: https://cordova.apache.org/docs/en/12.x/config_ref/images.html#adaptive-icon-with-colors
|
Docs example is incorrect, in the sense that it will produce the issue if followed. I think the intent is to show a simple example that can be derived from. With that being said, I'm considering proposing a change to rename
The filenames doesn't really matter as long as it doesn't already exists (cause if it exists, you will be overwriting them and will likely break something that depends on what was previously written in them). I'd suggest prefixing to avoid namespace clashing with cordova, or any other plugin. Something that will very likely be unique to your own project. Note that if you're creating a resource with a duplicate name (like if something already defines the <?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="myAppIconBackground">#FF0000</color>
</resources>
Your log indicates that it wrote the strings.xml file successfully. That is the
The file creation happens on the prepare step, which I don't think is ran on platform add (though I don't remember this clearly so I could be wrong). The If prepare is indeed running on platform add, but that file is still not being produced while the CLI is erroring on preparing the colors.xml/splashscreen (or any other non-zero exit code) I wouldn't fret too much because it could be nuances with OS signaling that the file is written but it's not actually flushed to disk and the error is causing the process to exit too early without waiting for flushes. In normal operations, the node program will not fully exit until all data streams are flushed, but that might not be the case if the node program is exiting early due to an error. |
The docs flat-out say to create a file named colors.xml. It's stated it in such a way that leaves little to no room for interpretation. To think that following the instructions from the official docs breaks your Cordova project in a way that's difficult to diagnose is less than ideal. |
Bug Report
Problem
I add this into my cordova project root config.xml file in the android platform node
The src file path does exist and it is valid XML
`res/values/colors.xml
What is expected to happen?
It should copy the resource to the target without complaint.
What does actually happen?
It does copy the resource file but it also spews out a non-specific error:
Information
From verbose logs
I should note that it's the error's context being after trying to write
strings.xml
prompted me to look for that file, and it's not being created. So/Users/me/code/App-CLMP/app/App/cordova/build/platforms/android/app/src/main/res/values/strings.xml
does not exist after the platform add command is run.Command or Code
Environment, Platform, Device
I'm running cordova on Mac OS X and trying to build it for Android API v13 for emulator.
Version information
Cordova: 12.0.0 ([email protected])
[email protected]
Mac OS X: 14.5 (23F79)
Android Studio Koala | 2024.1.1 Patch 1
Node: v20.15.1
Checklist
The text was updated successfully, but these errors were encountered: