Skip to content
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

cordova 9.0 cordova build --release error not match this qualifier [MissingDefaultResource] #214

Closed
3 tasks
jiwufeiyang opened this issue May 11, 2019 · 7 comments · Fixed by #337
Closed
3 tasks

Comments

@jiwufeiyang
Copy link

jiwufeiyang commented May 11, 2019

Bug Report

Problem

What is expected to happen?

> Task :app:lintVitalRelease
/platforms/android/app/src/main/res/drawable-port-hdpi/screen.9.png: Error: The drawable "screen" in drawable-port-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]
/platforms/android/app/src/main/res/drawable-port-ldpi/screen.9.png: Error: The drawable "screen" in drawable-port-ldpi 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]
/platforms/android/app/src/main/res/drawable-port-mdpi/screen.9.png: Error: The drawable "screen" in drawable-port-mdpi 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]
/platforms/android/app/src/main/res/drawable-port-xhdpi/screen.9.png: Error: The drawable "screen" in drawable-port-xhdpi 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]

   Explanation for issues of type "MissingDefaultResource":
   If a resource is only defined in folders with qualifiers like -land or -en,
   and there is no default declaration in the base folder (layout or values
   etc), then the app will crash if that resource is accessed on a device
   where the device is in a configuration missing the given qualifier.

   As a special case, drawables do not have to be specified in the base
   folder; if there is a match in a density folder (such as drawable-mdpi)
   that image will be used and scaled. Note however that if you  only specify
   a drawable in a folder like drawable-en-hdpi, the app will crash in
   non-English locales.

   There may be scenarios where you have a resource, such as a -fr drawable,
   which is only referenced from some other resource with the same qualifiers
   (such as a -fr style), which itself has safe fallbacks. However, this still
   makes it possible for somebody to accidentally reference the drawable and
   crash, so it is safer to create a default dummy fallback in the base
   folder. Alternatively, you can suppress the issue by adding
   tools:ignore="MissingDefaultResource" on the element.

   (This scenario frequently happens with string translations, where you might
   delete code and the corresponding resources, but forget to delete a
   translation. There is a dedicated issue id for that scenario, with the id
   ExtraTranslation.)

4 errors, 0 warnings

What does actually happen?

update Android cordova 9.0 cordova build --release error , but cordova build ok

config.xml

 <platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="res/android/ldpi.png" />
        <icon density="mdpi" src="res/android/mdpi.png" />
        <icon density="hdpi" src="res/android/hdpi.png" />
        <icon density="xhdpi" src="res/android/xhdpi.png" />
        <splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.9.png" />
        <splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.9.png" />
        <splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.9.png" />
        <splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.9.png" />
        <config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
            <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
            <uses-permission android:name="android.permission.INTERNET" />
        </config-file>
    </platform>

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@janpio
Copy link
Member

janpio commented May 11, 2019

Please don't just delete parts of the issue template - it is important that we know all the versions you are using etc.

Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

@jiwufeiyang
Copy link
Author

jiwufeiyang commented May 13, 2019

Bug Report

Problem

What is expected to happen?

cordova 9.0 cordova build --release

What does actually happen?

update Android cordova 9.0 cordova build --release error , but cordova build ok

Information

[wen@localhost chezixiang]$ cordova build --release
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/home/wen/android-sdk-linux (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app

Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Task :app:preBuild UP-TO-DATE
Task :CordovaLib:preBuild UP-TO-DATE
Task :CordovaLib:preReleaseBuild UP-TO-DATE
Task :CordovaLib:checkReleaseManifest UP-TO-DATE
Task :CordovaLib:processReleaseManifest UP-TO-DATE
Task :app:preReleaseBuild UP-TO-DATE
Task :CordovaLib:compileReleaseAidl NO-SOURCE
Task :app:compileReleaseAidl NO-SOURCE
Task :CordovaLib:packageReleaseRenderscript NO-SOURCE
Task :app:compileReleaseRenderscript UP-TO-DATE
Task :app:checkReleaseManifest UP-TO-DATE
Task :app:generateReleaseBuildConfig UP-TO-DATE
Task :app:prepareLintJar UP-TO-DATE
Task :app:generateReleaseSources UP-TO-DATE
Task :CordovaLib:compileReleaseRenderscript UP-TO-DATE
Task :CordovaLib:generateReleaseBuildConfig UP-TO-DATE
Task :CordovaLib:generateReleaseResValues UP-TO-DATE
Task :CordovaLib:generateReleaseResources UP-TO-DATE
Task :CordovaLib:packageReleaseResources UP-TO-DATE
Task :CordovaLib:generateReleaseRFile UP-TO-DATE
Task :CordovaLib:prepareLintJar UP-TO-DATE
Task :CordovaLib:generateReleaseSources UP-TO-DATE
Task :CordovaLib:javaPreCompileRelease UP-TO-DATE
Task :CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
Task :CordovaLib:processReleaseJavaRes NO-SOURCE
Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease UP-TO-DATE
Task :app:javaPreCompileRelease UP-TO-DATE
Task :app:mainApkListPersistenceRelease UP-TO-DATE
Task :app:generateReleaseResValues UP-TO-DATE
Task :app:generateReleaseResources UP-TO-DATE
Task :app:mergeReleaseResources UP-TO-DATE
Task :app:createReleaseCompatibleScreenManifests UP-TO-DATE
Task :app:processReleaseManifest
Task :app:processReleaseResources
Task :app:compileReleaseJavaWithJavac UP-TO-DATE
Task :app:compileReleaseNdk NO-SOURCE
Task :app:compileReleaseSources UP-TO-DATE

Task :app:lintVitalRelease
/home/wen/work/cordova/dep/chezixiang/platforms/android/app/src/main/res/drawable-port-hdpi/screen.9.png: Error: The drawable "screen" in drawable-port-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]
/home/wen/work/cordova/dep/chezixiang/platforms/android/app/src/main/res/drawable-port-ldpi/screen.9.png: Error: The drawable "screen" in drawable-port-ldpi 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]
/home/wen/work/cordova/dep/chezixiang/platforms/android/app/src/main/res/drawable-port-mdpi/screen.9.png: Error: The drawable "screen" in drawable-port-mdpi 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]
/home/wen/work/cordova/dep/chezixiang/platforms/android/app/src/main/res/drawable-port-xhdpi/screen.9.png: Error: The drawable "screen" in drawable-port-xhdpi 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]

Explanation for issues of type "MissingDefaultResource":
If a resource is only defined in folders with qualifiers like -land or -en,
and there is no default declaration in the base folder (layout or values
etc), then the app will crash if that resource is accessed on a device
where the device is in a configuration missing the given qualifier.

As a special case, drawables do not have to be specified in the base
folder; if there is a match in a density folder (such as drawable-mdpi)
that image will be used and scaled. Note however that if you only specify
a drawable in a folder like drawable-en-hdpi, the app will crash in
non-English locales.

There may be scenarios where you have a resource, such as a -fr drawable,
which is only referenced from some other resource with the same qualifiers
(such as a -fr style), which itself has safe fallbacks. However, this still
makes it possible for somebody to accidentally reference the drawable and
crash, so it is safer to create a default dummy fallback in the base
folder. Alternatively, you can suppress the issue by adding
tools:ignore="MissingDefaultResource" on the element.

(This scenario frequently happens with string translations, where you might
delete code and the corresponding resources, but forget to delete a
translation. There is a dedicated issue id for that scenario, with the id
ExtraTranslation.)

4 errors, 0 warnings

Task :app:mergeReleaseShaders UP-TO-DATE
Task :app:compileReleaseShaders UP-TO-DATE
Task :app:generateReleaseAssets UP-TO-DATE
Task :CordovaLib:mergeReleaseShaders UP-TO-DATE
Task :CordovaLib:compileReleaseShaders UP-TO-DATE
Task :CordovaLib:generateReleaseAssets UP-TO-DATE
Task :CordovaLib:packageReleaseAssets UP-TO-DATE
Task :app:mergeReleaseAssets
Task :app:signingConfigWriterRelease UP-TO-DATE
Task :app:transformClassesWithDexBuilderForRelease UP-TO-DATE
Task :app:transformDexArchiveWithExternalLibsDexMergerForRelease UP-TO-DATE
Task :app:transformDexArchiveWithDexMergerForRelease UP-TO-DATE
Task :app:mergeReleaseJniLibFolders UP-TO-DATE
Task :CordovaLib:compileReleaseNdk NO-SOURCE
Task :CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
Task :CordovaLib:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
Task :CordovaLib:transformNativeLibsWithIntermediateJniLibsForRelease UP-TO-DATE
Task :app:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
Task :app:processReleaseJavaRes NO-SOURCE
Task :app:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
Task :app:packageRelease
Task :app:assembleRelease
Task :app:cdvBuildRelease

BUILD SUCCESSFUL in 2s
42 actionable tasks: 5 executed, 37 up-to-date
Built the following apk(s):
/home/wen/work/cordova/dep/chezixiang/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk

Command or Code

config.xml

preference name="Orientation" value="portrait" />
preference name="SplashScreen" value="screen" />
preference name="SplashScreenDelay" value="3800" />
preference name="auto-hide-splash-screen" value="ture" />
platform name="android">
allow-intent href="market:*" />
icon density="ldpi" src="res/android/ldpi.png" />
icon density="mdpi" src="res/android/mdpi.png" />
icon density="hdpi" src="res/android/hdpi.png" />
icon density="xhdpi" src="res/android/xhdpi.png" />
splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.9.png" />
splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.9.png" />
splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.9.png" />
splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.9.png" />
/platform>

Environment, Platform, Device

environment : Android

Version information

Cordova version (cordova -v):9.0.0 (cordova-lib@9.0.1)

Cordova platform version (cordova platform ls):
Installed platforms:
android 8.0.0

$cordova plugin list
cordova-open 1.0.12 "Open"
cordova-plugin-alipay-v2 1.0.0 "alipay"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-jcore 1.2.8 "JCore"
cordova-plugin-media 5.0.2 "Media"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-progressdialog 2.0.1 "XYDialog"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-wechat 2.8.0 "Wechat"
cordova-plugin-whitelist 1.3.3 "Whitelist"
jpush-phonegap-plugin 3.6.4 "JPush"

Other Frameworks: Eclipse edit, Teminal build

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

@phipier
Copy link

phipier commented Jun 25, 2019

Any news on this? I am having the same error in same context

@Overman775
Copy link

Try this config lines:

    <splash density="hdpi" src="res/screen/android/splash-port-hdpi.png" />
    <splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.png" />
    <splash density="ldpi" src="res/screen/android/splash-port-ldpi.png" />
    <splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.png" />
    <splash density="mdpi" src="res/screen/android/splash-port-mdpi.png" />
    <splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.png" />
    <splash density="xhdpi" src="res/screen/android/splash-port-xhdpi.png" />
    <splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.png" />

Read this apache/cordova-android#689

@Ahsanmughal
Copy link

Ahsanmughal commented Oct 29, 2019

Any solution for this cordova build --release error not match the src in the config.xml file ? same error in the same context. @phipier @Overman775 @janpio

@RafaelLVX
Copy link

RafaelLVX commented Nov 20, 2019

I had the same issue. Here's how I made the error go away.

Originally I had the following within <platform name="android"> ... </platform> in config.xml:

<splash density="land-hdpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="land-ldpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="land-mdpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="land-xhdpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="port-hdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="port-ldpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="port-mdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="port-xhdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />

Note how I actually use one file for all portrait resolutions and one for all landscape resolutions. For me lower resolutions don't matter so I only used the high resolution file and prayed it wouldn't trouble me later (so far it hadn't but I couldn't test on that many devices). Either way, you'll see where I'm getting.

What solved the problem for me was adding lines with densities that don't specify orientation, thusly:

<splash density="hdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="ldpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="mdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="xhdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="land-hdpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="land-ldpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="land-mdpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="land-xhdpi" src="res/screen/android/RafaelLVX-splashscreen-ls.png" />
<splash density="port-hdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="port-ldpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="port-mdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />
<splash density="port-xhdpi" src="res/screen/android/RafaelLVX-splashscreen.png" />

Now note I used the portrait orientation files for these no-orientation-densities. In truth I don't know if that matters, I don't know what circumstances will fall back to these paths. Maybe the files should be square here? I don't know. Hoping to avoid that the app defaults to this uncertain configuration I added these new lines BEFORE the tried and true landscape and portrait config. All I know is that it worked. If anyone knows more, please let us know what I did right and how to improve this. ;-)

Thanks @apiaget in this post for pointing in the right direction.

@xancel89
Copy link

Try this config lines:

    <splash density="hdpi" src="res/screen/android/splash-port-hdpi.png" />
    <splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.png" />
    <splash density="ldpi" src="res/screen/android/splash-port-ldpi.png" />
    <splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.png" />
    <splash density="mdpi" src="res/screen/android/splash-port-mdpi.png" />
    <splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.png" />
    <splash density="xhdpi" src="res/screen/android/splash-port-xhdpi.png" />
    <splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.png" />

Read this apache/cordova-android#689

work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants