Lyfei opened a new issue, #1576:
URL: https://github.com/apache/cordova-android/issues/1576
# Bug Report
## Problem
### What is expected to happen?
add android platform
### What does actually happen?
get error: Cannot read property 'find' of null
## Information
Cordova Packages:
cli: 11.0.0
common: 4.1.0
create: 4.1.0
lib: 11.1.0
common: 4.1.0
fetch: 3.1.0
serve: 4.0.1
Project Installed Platforms:
android: 11.0.0
ios: 6.2.0
Environment:
OS: macOS Monterey 12.6.3 (21G419) (darwin 21.6.0) x64
Node: v12.14.0
npm: 6.14.10
### Command or Code
<!-- What command or code is needed to reproduce the problem? -->
```shell
$ ionic cordova platform add android@latest --verbose
# ...
Cannot read property 'find' of null
TypeError: Cannot read property 'find' of null
at /.../node_modules/cordova-android/lib/prepare.js:387:49
at Array.forEach (<anonymous>)
at updateProjectSplashScreen
(/.../node_modules/cordova-android/lib/prepare.js:384:7)
at updateProjectAccordingTo
(/.../node_modules/cordova-android/lib/prepare.js:269:5)
at /.../node_modules/cordova-android/lib/prepare.js:67:21
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
```
I found the reason on prepare.js:
```diff
function updateProjectSplashScreen (platformConfig, locations) {
// res/values/themes.xml
const themes = xmlHelpers.parseElementtreeSync(locations.themes);
const splashScreenTheme =
themes.find('style[@name="Theme.App.SplashScreen"]');
[
'windowSplashScreenAnimatedIcon',
'windowSplashScreenAnimationDuration',
'windowSplashScreenBackground',
'windowSplashScreenBrandingImage',
'windowSplashScreenIconBackgroundColor',
'postSplashScreenTheme'
].forEach(themeKey => {
const cdvConfigPrefKey = 'Android' +
themeKey.charAt(0).toUpperCase() + themeKey.slice(1);
const cdvConfigPrefValue =
platformConfig.getPreference(cdvConfigPrefKey, this.platform);
- let themeTargetNode =
splashScreenTheme.find(`item[@name="${themeKey}"]`);
+ let themeTargetNode = splashScreenTheme ?
splashScreenTheme.find(`item[@name="${themeKey}"]`) : null;
```
If you change this line, you can add android successfully
## 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]