0

I'm using Cordova to wrap an Angular project into an Android apk. It worked a few months ago (without custimized icon though, if I remember correctly).

When I want to create a release build for Android with cordova build android --release now, I get the following error message:

BUILD FAILED in 26s
D:\[...]\Cordova\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.Aapt2Exception: Android resource compilation failed
  D:\[...]\Cordova\platforms\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.

Expected result: working .apk Actual result: no apk, aborted build process

The png is created in the building process, therefore I think the problem lies within the Cordova libs.

Cordova has been on version 10 before, while trying to fix the build process I stepped down to Version 9 [9.0.0 (cordova-lib@9.0.1)]. 9.1.0 wasn't found (Release Notes from the Blog), when I tried to install it.

When I remove the icon from the config.xml it shows the following error message:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Android resource linking failed
  D:\[...]\Cordova\platforms\android\app\build\intermediates\merged_manifests\release\AndroidManifest.xml:50: AAPT: error: resource mipmap/ic_launcher (aka [id]:mipmap/ic_launcher) not found.

  error: failed processing manifest.

Editing the Android manifest itself does not work as it also created/updated during the building process.

I ran the exiftool for the created png and it showed the following output:

"exiftool(-k).exe" ic_launcher.png
ExifTool Version Number         : 12.32
File Name                       : ic_launcher.png
Directory                       : .
File Size                       : 15 KiB
File Modification Date/Time     : 2021:07:16 14:09:50+02:00
File Access Date/Time           : 2021:10:04 14:41:23+02:00
File Creation Date/Time         : 2021:10:04 14:41:22+02:00
File Permissions                : -rw-rw-rw-
Error                           : File format error
-- press ENTER --

This strengthens my suspicion that the error is inside the libs themselves.

The config.xml looks like this:

<?xml version='1.0' encoding='utf-8'?>
<widget id="[---]" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>[---]</name>
    <description>
        [---]
    </description>
    <author email="[---]">
        [---]
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <icon src="www/assets/favicon.ico" platform="android" width="48" height="48" density="mdpi" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

I also checked for the similar question here, but I haven't found a solution for my problem. In my opinion or what I found so far I think a fix in the libs is necessary or I overlooked something. So a workaround would be sufficient, too.

  • correction: [This](https://stackoverflow.com/questions/46177560/failed-to-read-png-signature-file-does-not-start-with-png-signature/47254670) is the actual second link I meant, whose solution suggestions I tried. But the original link doesn't have working solutions, too. – Envinyatar Oct 06 '21 at 13:42
  • Worked when just using a .png instead of the .ico in the assets folder... – Envinyatar Oct 11 '21 at 09:42

0 Answers0