apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.67k stars 1.54k forks source link

Java exception when doing an android build #1552

Closed jondspa closed 1 year ago

jondspa commented 1 year ago

Bug Report

Problem

Getting a Java exception when doing a build on a freshly installed system. I've been trying to update my Cordova app to API 31. I've been having trouble so decided to do a fresh install on a new machine. Loaded everything new but getting the below errors.

Many thanks for any advice! Jon

What is expected to happen?

Build would succeed.

What does actually happen?

Getting this error message on first build. The error continues for another 100 or so lines. Repeated several times.

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Not a number: 33x: java.lang.NumberFormatException: Not a number: 33x at com.sun.xml.bind.DatatypeConverterImpl._parseInt(DatatypeConverterImpl.java:95) at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$18.parse(RuntimeBuiltinLeafInfoImpl.java:712) at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$18.parse(RuntimeBuiltinLeafInfoImpl.java:710) at com.sun.xml.bind.v2.runtime.unmarshaller.TextLoader.text(TextLoader.java:39) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:560) at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:183) at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:146) at java.xml/org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:570) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:610) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1718) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2883) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)

On subsequent builds:

Execution failed for task ':app:mergeReleaseResources'.

Multiple task action failures occurred: A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable AAPT2 aapt2-4.2.2-7147631-osx Daemon #3: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable AAPT2 aapt2-4.2.2-7147631-osx Daemon #0: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable AAPT2 aapt2-4.2.2-7147631-osx Daemon #2: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable AAPT2 aapt2-4.2.2-7147631-osx Daemon #1: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable AAPT2 aapt2-4.2.2-7147631-osx Daemon #6: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable AAPT2 aapt2-4.2.2-7147631-osx Daemon #4: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable AAPT2 aapt2-4.2.2-7147631-osx Daemon #5: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does.

Information

Command or Code

Cordova build android --release

Environment, Platform, Device

Mac OS 12.5

Version information

Cordova version 11.1.0 Cordova-android 10.1.2 target SDK version 31 Gradle version 7.6 Gradle wrapper 7.1 Android build tools 30.0.3 Java version 11.0.17

Checklist

breautek commented 1 year ago

Compiling/targeting API 31+ requires build tools 31+. I believe this is why AAPT is failing.

Cordova-android@10 doesn't officially support targeting API 31+. The project should be upgraded to cordova-android@11.

Build tools 31+ also requires Java11, which I see you are already using.

If it's not possible or feasible to upgrade, then you might be able to get by by setting android-targetSdkVersion to 31, and android-buildToolsVersion to 31.0.0 (version should match the installed version identically... so if yoi have version 31.0.1 installed then the preference value should match. As cordova-android@10 doesn't support API 31, your mileage may vary.

If neither upgrading to cordova-android@11 or my hack workaround works for you, then like the error says a bug should be reported, but it should be reported to the Android SDK, which can be done here.

If you have further questions, don't hesitate to ask, but I'll be closing this issue as the reported stack trace indicates a bug with AAPT, not Cordova.