apache / apache/cordova-android

colors.xml resource causes platform error "Cannot set properties of null (setting 'text')"

Open
#1,728 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.8k
Forks
1.6k
Avg merge
16h 18m
Merged PRs (30d)
11

Description

# 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
```

#F1511A

```
### 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:
```
Cannot set properties of null (setting 'text')
```

## Information

From verbose logs
```
Wrote out android application name "MyApp" to /Users/me/code/App-CLMP/app/App/cordova/build/platforms/android/app/src/main/res/values/strings.xml
Cannot set properties of null (setting 'text')
TypeError: Cannot set properties of null (setting 'text')
at updateProjectSplashScreenBackgroundColor (/Users/me/code/App-CLMP/app/App/cordova/build/node_modules/cordova-android/lib/prepare.js:499:68)
at updateProjectSplashScreen (/Users/me/code/App-CLMP/app/App/cordova/build/node_modules/cordova-android/lib/prepare.js:393:5)
at updateProjectAccordingTo (/Users/me/code/App-CLMP/app/App/cordova/build/node_modules/cordova-android/lib/prepare.js:274:5)
at /Users/me/code/App-CLMP/app/App/cordova/build/node_modules/cordova-android/lib/prepare.js:69:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 0)
me@MacBook-Pro build %
```

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

```
cordova platform remove android; cordova platform add android;
```

### 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 (cordova-lib@12.0.1)
cordova-android@13.0.0
Mac OS X: 14.5 (23F79)
Android Studio Koala | 2024.1.1 Patch 1
Node: v20.15.1

## Checklist

- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Reproduce the problem with `cordova platform remove android; cordova platform add android;`, then inspect `lib/prepare.js`, especially `updateProjectSplashScreenBackgroundColor` at line 499 and its callers. Compare the handling of the generated `strings.xml` with the supplied `resource-file`; done means the platform add completes without the null-property error while copying the resource as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
build-system, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.