-
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
Build errors about drawable since upgrading to v8.0.0 #689
Comments
It only happens with a production "release" build. |
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? |
@dpogue I can confirm that the build succeeds but the sub task
|
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 |
I can confirm that suggestion by @apiaget makes error/ warnings go away. I have renamed resources with |
True. Adding additionally the density without |
OK so apparently there are a few more: https://developer.android.com/guide/topics/manifest/activity-element.html#screen |
@marckassay thanks a lot. Could you elaborate how the splash screen should look different from "default" mode to portrait mode? And what exactly this https://gist.github.com/marckassay/913c06fac2a64a25ae9115435f8195d3/revisions?diff=unified#diff-1c17390bf45f1534c828cbeea42bb0deR7 "background / foreground" is |
@BorntraegerMarc my intention of that gist diff was just to highlight what @apiaget modified, to have the error disappear, which is seen in this illustration: The "background / foreground" that you're referring to applies to app icons. I don't think that's relevant to the issue you reported. Fyi, an alternative to using 'cordova-plugin-splashscreen' can be cordova-plugin-lottie-splashscreen which may be an interest to you. If you're unfamiliar with this plugin, it uses Lottie.
I attempted to implemented this as a replacement to 'cordova-plugin-splashscreen' but was unable to find any available animations fitting to my needs. Manually modifying the json is difficult since it's hardly readable and installing Adobe After Effects wasn't something I was going to do. |
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 |
@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 It will nice to see the day when we just provide a background and foreground vector values. |
package.json:
config.xml add: |
I've solved creating a new directory and copying the icon as described here: |
The adjustment to config.xml made by apiaget fixed it for me.Thank you for the input everyone. |
Any solution found? |
Does this error occur if you run @KasunGamage - your AAPT error isn't the same one from above. Try this Github issue: arnesson/cordova-plugin-firebase#1081 |
I have the same problem I have not found anything yet, could you solve it? |
what does this dO? |
To solve this error I create a diretory 'drawable' na pasta 'platforms\android\app\src\main\res' After that I copied the file screen.png and ic_launcher.png to the folder 'drawable. |
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. |
@apiaget's answer is correct. You should provide default resources.
I also wrote more explanation and made a pull request to fix the docs. |
@apiaget I've added:
with little luck, this doesn't seem to work |
Why my image paths is different from @apiaget ?? |
Yes i had to update android studio along with gradle 3.5 and distributionUrl to 5.4.1-all. This is all happening due to splashscreen file size if you are having splash.png less than 100kb then it works great even with current gradle 3.3.0 otherwise it will give above error. |
Thanks ppetree, this fixed it for me as well. |
In addition to removing "port-" from the portrait splashes, I had another app with large 32-bit png splashes that generated the same error, had to drop them all to 8-bit, so there is some size issue as well for the --release build as noted above. |
This seems to have worked for me 🤔 |
All that does is hide the error messages, it doesn't actually "solve" the problem. |
Oh. So which is the right solution? |
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. |
This works for me, thanks |
(Note this is an almos 1 to 1 copy of apache#228 by @toshihidetagami ### Platforms affected Only docs ### Motivation and Context Current documentation lacks the default resources for Android. On Android, you can provide alternative resources for specific device configuration, like current docs provide alternative resources for portrait and landscape orientation. But error will be thrown if a device configuration does not match any specific alternative resources, so you should provide a default (In this case, without port- or land- ) as a fallback. This change fixes the error reported in apache#185 and [apache/cordova-android#689](apache/cordova-android#689). ### Description [Although orientation is only portrait and landscape as of now](https://developer.android.com/guide/topics/resources/providing-resources#OrientationQualifier), providing default would prevent [MissingDefaultResource lint check error](http://tools.android.com/tips/lint-checks) and considered as [good practice for Android resources configuration](https://developer.android.com/guide/topics/resources/providing-resources#Compatibility). > Likewise, if you provide different layout resources based on the screen orientation, you should pick one orientation as your default. For example, instead of providing layout resources in layout-land/ for landscape and layout-port/ for portrait, leave one as the default, such as layout/ for landscape and layout-port/ for portrait. Note: You don’t have to provide a default for screen density. [The system use whichever resources are the best match](https://developer.android.com/guide/topics/resources/providing-resources#DensityQualifier). ### Testing ### Checklist * [ ] I've run the tests to see all new and existing tests pass * [ ] I added automated test coverage as appropriate for this change * [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`) * [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/)) * [x] I've updated the documentation if necessary
Solution from @apiaget worked, I don't understand though why should I have the tag |
The resources (icon, splash) should be added automatically to the config.xml when adding the android platform. That worked some time ago, right? Maybe it does not work since the platform is stored in package.json? Anyway, the config.xml should contain the platform tag with all the required settings incl. icons and splashes. Automatically. |
And the icons can be set by following this docs. I just expected that this configuration is added automatically on adding the Android platform and / or plugin installation. (The standard icons). But ok, you have to add this manually. I think my memories of automatically set resources are from Ionic. I thought it was Cordova. Sorry. (Not sure. But anyway... an predefined config is not the worst idea. e.g. changing the Icons is an essential configuration.) |
Confirmed: Adding the density without "land-" or "port-" fixes the issue. But what's the correct sizes? Is the default density (without prefix) for portait (port)? So I can use the same images or better, remove the density with prefix "port-"? <splash density="ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/>
<splash density="mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/>
<splash density="hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/>
<splash density="xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/>
<splash density="xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/>
<splash density="xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/>
<splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png"/>
<splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png"/>
<splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png"/>
<splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png"/>
<splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png"/>
<splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png"/>
<!-- This can be removed: -->
<splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/>
<splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/>
<splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/>
<splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/>
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/>
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/> Is this correct? Currently I have all three kinds. UPDATE 1: UPDATE 2: For the sake of completeness. This was my initial error without the default density:
I would be very grateful for any clarification. 🙏 |
Adding these plugins removed any build error for me. |
the same problem,cordova-android 8.1.0 `* What went wrong:
|
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.
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. |
The cordova splash plugin is not required to fix the "MissingDefaultResource" errors. You need to add something like the following to your config.xml file to define the defaults/fallbacks: <splash src="res/screen/android/splash-port-hdpi.png" density="hdpi"/>
<splash src="res/screen/android/splash-port-ldpi.png" density="ldpi"/>
<splash src="res/screen/android/splash-port-mdpi.png" density="mdpi"/>
<splash src="res/screen/android/splash-port-xhdpi.png" density="xhdpi"/>
<splash src="res/screen/android/splash-port-xxhdpi.png" density="xxhdpi"/> See cordova docs for more details. |
Currently, we copy default splash screens to the platform folder during platform creation, but then we do not delete them when the user uses no splash screens at all. This causes #1226 and what is described in #689. The new implementation does not return early when updating splashes and none are defined. Instead, we let the cleanup map we create initially take care of deleting all unused splash screens. This also deletes the default splashes during the first prepare after platform creation. Fixes #1226
The best solution is to add all your density files under www folder and point to them.
` |
Currently, we copy default splash screens to the platform folder during platform creation, but then we do not delete them when the user uses no splash screens at all. This causes apache#1226 and what is described in apache#689. The new implementation does not return early when updating splashes and none are defined. Instead, we let the cleanup map we create initially take care of deleting all unused splash screens. This also deletes the default splashes during the first prepare after platform creation. Fixes apache#1226
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:
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
Checklist
The text was updated successfully, but these errors were encountered: