cordova-android: Build errors about drawable since upgrading to v8.0.0
Bug Report
Problem
What is expected to happen?
Building a cordova app with ionic cordova build android --prod --release
does not throw errors.
What does actually happen?
I see this error in the console:
/platforms/android/app/src/main/res/drawable-land-hdpi/screen.png: Error: The drawable "screen" in drawable-land-hdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
Information
This error was not present in v7.X
I do specify a splash screen in config.xml
like so: <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
And it gets displayed correctly (according to my tests so far)
I’m using this plugin to configure the splash screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/
I only included 1 example of the errors I’m getting to keep the bug report small. But I get it for different screen sizes & densities.
I understand that it has something to do with android linting rules: http://tools.android.com/tips/lint-checks
But I don’t fully understand if it’s a misconfiguration in the plugin or if cordova-android needs to do something differently.
Command or Code
ionic cordova build android --prod --release
Environment, Platform, Device
On all. It happens on build time.
Version information
~/Documents/komed/komed-frontend$ ionic info
Ionic:
ionic (Ionic CLI) : 4.11.0 (/Users/borntsch/.nvm/versions/node/v8.13.0/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.3
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 8.0.0, browser 5.0.4, ios 5.0.0
Cordova Plugins : cordova-plugin-ionic-webview 2.3.1, (and 27 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/borntsch/Library/Android/sdk)
ios-deploy : 1.9.2
ios-sim : 7.0.0
NodeJS : v8.13.0 (/Users/borntsch/.nvm/versions/node/v8.13.0/bin/node)
npm : 6.4.1
OS : macOS Mojave
Xcode : Xcode 10.1 Build version 10B61
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 31
- Comments: 53 (2 by maintainers)
Commits related to this issue
- work around android release build choking on some missing splash config (https://github.com/apache/cordova-android/issues/689) — committed to nabto/ionic-starter-nabto-video by gammelby 5 years ago
- Update missing Docs about default resources for Android (Note this is an almos 1 to 1 copy of https://github.com/apache/cordova-plugin-splashscreen/pull/228 by @toshihidetagami ### Platforms affec... — committed to distante/cordova-plugin-splashscreen by distante 4 years ago
- config now has all the plugins also, and avoids bug on release: https://github.com/apache/cordova-android/issues/689#issuecomment-473992821 — committed to jfoclpf/form-for-parking-violation by jfoclpf 4 years ago
- Fix Android missing splash resource errors See https://github.com/apache/cordova-android/issues/689#issuecomment-473992821 — committed to webful-ltd/passwordmaker by NoelLH 3 years ago
- fix(prepare): delete splash screens if none are used (#1227) Currently, we copy default splash screens to the platform folder during platform creation, but then we do not delete them when the user us... — committed to apache/cordova-android by raphinesse 3 years ago
- fix(prepare): delete splash screens if none are used (#1227) Currently, we copy default splash screens to the platform folder during platform creation, but then we do not delete them when the user us... — committed to wedgberto/cordova-android by raphinesse 3 years ago
Hello all !
This error also appears when I do release build after upgrading to cordva-android@8.0.0.
I noticed that the error/warning disappear when I do the following modifications in my config.xml file:
Before (the following rises 4 errors/warning):
After (the following rises no error/warning):
Do you think that adding the “default” densities is correct to solve this problem (hdpi, ldpi, mdpi and xhdpi in my case) or is the error caused by something else ? In fact I do not really know if I am really solving the problem or just workarounding it…
apiaget
It only happens with a production “release” build.
Here is a gist diff of @apiaget’s before and after.
@dpogue I can confirm that the build succeeds but the sub task
> Task :app:lintVitalRelease
seems to fail (but it doesn’t cause the full build to fail). Not sure how to explain. Here’s my output:In the portrait images, take off the “port-” so they just have the resolution like this: port-ldpi to ldpi
Only do this on the portrait images! Report back.
Sent from my iPad, please excuse typos and autocorrects.
package.json:
cordova plugin add cordova-plugin-splashscreen
npm install
config.xml add: …
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
…FWIW, this issue still exists in 9.0.0.
The config.xml updates didn’t work for me, unfortunately, However, adding this to my project_root/build-extras.gradle resolved the issue:
Then I added a hook like this to copy it to the build folder: https://github.com/QuantiModo/quantimodo-android-chrome-ios-web-app/blob/develop/hooks/build-extras-hook.js
I can confirm that suggestion by @apiaget makes error/ warnings go away.
I have renamed resources with
density="port-*"
todensity="*"
since there is only portrait mode in the my appAdding these plugins removed any build error for me.
Hi all, I tried all of the above solutions but it still didn’t work. Is there anyone like me?
I have tried to add this in the config.xml
And tried to change build.gradle like @mikepsinn .
I would appreciate any suggestions could help me.
Closing this issue because it’s old and obsolete. I’ll summarise the problem and potential solutions below.
This problem can be caused by one or a mixture of:
[1] Linked reference is for cordova-android@9. cordova-android@8 is no longer google play store compliant and is not supported.
@coloz
This is not the same problem. And it sounds like you’re running into an unhandled failure case inside AAPT, which is an android tool. So that’s where that error should be reported. Additionally you can double check and ensure you’re running the latest patch of the android build tools.
Changing the config entry seems to solve the problem. The images display properly and the warnings and errors go away. This is the workaround until either cordova is fixed OR the docs are fixed.
All that does is hide the error messages, it doesn’t actually “solve” the problem.
Same problem. Resolve by converting my PNG 32 bit color splashcreen image to PNG 24.
To solve these errors, go to:
and in your build.gradle file add this line “checkReleaseBuilds false;” inside lintOptions block like this:
Hope it helps.
@piotr-cz you may be right. It seems those attributes are, as you have listed, for adaptive icons for Android devices too, where the icons can be in a various shapes. Such as these:
And config.xml supports fallback for devices that don’t have this feature.
Where the value of
src
, in this example, is a png file.It will nice to see the day when we just provide a background and foreground vector values.
ref: Cordova/Images/Adaptive Icons
foreground/ background attributes may be related to new Google Play app icon specifications - am I right, @marckassay ?
Android Developers blog: Introducing a new Google Play app and game icon specification Android Developers > Docs > Adaptive icons
I’ve seen this too, but even though it says “Error” in the message, it seems more like a warning in that it seems to produce a working build. @BorntraegerMarc can you confirm that this is not causing your build to fail?