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

com.android.builder.internal.aapt.v2.Aapt2InternalException #880

Closed
3 tasks done
indraraj26 opened this issue Dec 4, 2019 · 9 comments
Closed
3 tasks done

com.android.builder.internal.aapt.v2.Aapt2InternalException #880

indraraj26 opened this issue Dec 4, 2019 · 9 comments

Comments

@indraraj26
Copy link

indraraj26 commented Dec 4, 2019

Bug Report

Problem

It is working fine when i am building without release option.
Release option was working fine with android version 7.1.4

What is expected to happen?

it should build successfully

What does actually happen?

cordova build android --release

Information

build gradle file:
https://gist.github.com/indraraj26/a6efaed1135b0e394a23a1b192bc2c0c

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.0-5013011-windows Daemon #0: Unexpected error during compile 'D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png', attempting to stop daemon. FAILED
20 actionable tasks: 1 executed, 19 up-to-date

  This should not happen under normal circumstances, please file an issue if it does.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s

D:\client>if "1" == "0" goto mainEnd

D:\client>rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of

D:\client>rem the _cmd.exe /c_ return code!

D:\client>if not "" == "" exit 1

D:\client>exit /b 1
Command finished with error code 1: D:\client\platforms\android\gradlew cdvBuildRelease,-b,D:\client\platforms\android\build.gradle
D:\client\platforms\android\gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.0-5013011-windows Daemon #0: Unexpected error during compile 'D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png', attempting to stop daemon.
  This should not happen under normal circumstances, please file an issue if it does.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Picked up _JAVA_OPTIONS: -Xmx512M
Error: D:\client\platforms\android\gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.0-5013011-windows Daemon #0: Unexpected error during compile 'D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png', attempting to stop daemon.
  This should not happen under normal circumstances, please file an issue if it does.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Picked up _JAVA_OPTIONS: -Xmx512M
    at ChildProcess.whenDone (D:\client\node_modules\cordova-common\src\superspawn.js:135:23)
    at ChildProcess.emit (events.js:198:13)
    at ChildProcess.cp.emit (D:\client\node_modules\cordova-common\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android --release --verbose exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

Command or Code

Environment, Platform, Device

Version information

ionic info
[WARN] Detected locally installed Ionic CLI, but it's too old--using global CLI.

Ionic:

   Ionic CLI          : 5.4.4 (C:\Users\HP\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.2

Cordova:

   Cordova CLI       : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-webview 1.2.1, (and 15 other plugins)

Utility:

   cordova-res : 0.8.1
   native-run  : 0.2.9

System:

   Android SDK Tools : 26.1.1 (C:\Users\HP\AppData\Local\Android\Sdk)
   NodeJS            : v10.16.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.10.2
   OS                : Windows 10

Checklist

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

with this solution : https://stackoverflow.com/a/50973967/10842900
i am able to build apk but getting this errors


D:\client\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]
D:\client\platforms\android\app\src\main\res\drawable-land-ldpi\screen.png: Error: The drawable "screen" in drawable-land-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]
D:\client\platforms\android\app\src\main\res\drawable-land-mdpi\screen.png: Error: The drawable "screen" in drawable-land-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]
D:\client\platforms\android\app\src\main\res\drawable-land-xhdpi\screen.png: Error: The drawable "screen" in drawable-land-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]
D:\client\platforms\android\app\src\main\res\drawable-land-xxhdpi\screen.png: Error: The drawable "screen" in drawable-land-xxhdpi 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]
D:\client\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png: Error: The drawable "screen" in drawable-land-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]
D:\client\platforms\android\app\src\main\res\drawable-port-hdpi\screen.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]
D:\client\platforms\android\app\src\main\res\drawable-port-ldpi\screen.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]
D:\client\platforms\android\app\src\main\res\drawable-port-mdpi\screen.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]
D:\client\platforms\android\app\src\main\res\drawable-port-xhdpi\screen.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]
D:\client\platforms\android\app\src\main\res\drawable-port-xxhdpi\screen.png: Error: The drawable "screen" in drawable-port-xxhdpi 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]
D:\client\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]

   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

@breautek
Copy link
Contributor

breautek commented Dec 4, 2019

cordova-android 7.x is no longer supported because it doesn't work with target SDK 28. If you're intending to publish your app to the Google Play store, Google requires you to target SDK 28 at the very minimum. Therefore you should upgrade to cordova-android@8. It targets SDK 28 by default.

This may or may not solve your issue, but I'd first start there.

@indraraj26
Copy link
Author

indraraj26 commented Dec 4, 2019

what i was trying to say it was working fine when we were using android 7.x but now i am getting above error. Still i am not able to figure out how to resolve this issue? Could you please share me the additional step to resolve?

Edit: Above error i am getting only with release option in cordova android 8.1.0

#689

@breautek
Copy link
Contributor

breautek commented Dec 4, 2019

See #689 (comment) for a potential workaround

what i was trying to say it was working fine when we were using android 7.x but now i am getting above error

My best guess is likely a tooling update in the android sdk.

@indraraj26
Copy link
Author

indraraj26 commented Dec 4, 2019

there is no land-* density so if user switched to landscape mode then default hdpi, ldpi will be used ?

i have made the changes but still same error i am getting

    <platform name="android">
        <preference name="loadUrlTimeoutValue" value="700000" />
        <allow-intent href="market:*" />
        <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/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.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="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" />
        <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" />
    </platform>

apache/cordova-plugin-splashscreen#185

@nhhockeyplayer
Copy link

this continues to be a blocker

Ionic:

   Ionic CLI                     : 5.2.8 (C:\Users\owner\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.803.24
   @angular-devkit/schematics    : 8.3.24
   @angular/cli                  : 8.3.24
   @ionic/angular-toolkit        : 2.1.2

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : cordova-plugin-ionic 5.4.6, cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 9 other plugins)

Utility:

   cordova-res : 0.6.0
   native-run  : not installed

System:

   Android SDK Tools : 26.1.1 (C:\Users\owner\AppData\Local\Android\Sdk)
   NodeJS            : v12.3.1 (C:\Program Files\nodejs\node.exe)
   npm               : 6.13.6
   OS                : Windows 7

@indraraj26
Copy link
Author

#689 (comment)

@breautek
Copy link
Contributor

If upgrading the gradle plugin was the solution, then this may be indirectly fixed by #951 which upgrades the gradle plugin to properly support the ANDROID_SDK_ROOT environment variable.

@breautek
Copy link
Contributor

Closing as #951 was merged in.

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

No branches or pull requests

3 participants