본문 바로가기
C++ 200제/코딩 IT 정보

안드로이드 The drawable "screen" in drawable-port-xxxhdpi ... 해결

by vicddory 2020. 5. 23.

IONIC 5 + 안드로이드 + CORDOVA 조합 활용 시 발생하는 오류인데, Android 자체가 갖고있는 에러입니다.


ionic cordova build android --minifycss --optimizejs --minifyjs --release


release를 할 때, 최적화 옵션을 주면 에러가 발생하는 에러죠.


D:\workingFolder\platforms\android\app\src\main\res\
drawable-port-xxxhdpi\screen.png:
Error: The drawable "screen" in drawable-port-xxxhdpi 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]


결론부터 말씀드리면 안드로이드 플랫폼 res 폴더 아래에 "ldpi~xxxhdpi" 이름의 density가 없어서 발생하는 겁니다.



개인적으론 조금 황당한 에러라고 생각합니다.


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.)

12 errors, 0 warnings


이런 안드로이드 오류 해결방법은 간단합니다.


config.xml에 port~ land~ 이름의 <splash density 들을 모두 복사하면 됩니다.


<splash density="port-ldpi"
 src="resources/android/splash/drawable-port-ldpi-screen.png" />


위의 splash를 복사해 아래처럼 추가하면 돼요.


<splash density="ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />


당연히 이런 파일은 여러개인데, 그걸 일일이 모두 복사하여 같은 작업을 합니다.


안드로이드 config.xml 파일을 수정하면 아래처럼 구성됩니다.


<icon density="ldpi"
 src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi"
 src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi"
 src="resources/android/icon/drawable-hdpi-icon.png" />
<icon density="xhdpi"
 src="resources/android/icon/drawable-xhdpi-icon.png" />
<icon density="xxhdpi"
 src="resources/android/icon/pikachu-xxhdpi-icon.png" />
<icon density="xxxhdpi"
 src="resources/android/icon/drawable-xxxhdpi-icon.png" />
<splash density="ldpi"
 src="resources/android/splash/drawable-land-ldpi-screen.png" />
<splash density="mdpi"
 src="resources/android/splash/drawable-land-mdpi-screen.png" />
<splash density="hdpi"
 src="resources/android/splash/drawable-land-hdpi-screen.png" />
<splash density="xhdpi"
 src="resources/android/splash/drawable-land-xhdpi-screen.png" />
<splash density="xxhdpi"
 src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
<splash density="xxxhdpi"
 src="resources/android/splash/drawable-land-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" />
<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/pikachu-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="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/pikachu-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" />


IONIC 5 + 안드로이드 + CORDOVA 조합 활용 시 발생하는 오류인 Error: The drawable "screen" in drawable-port-xxxhdpi has no declaration ... 해결 완료입니다.


댓글