2
votes

I could use command ionic cordova build android to build my project to apk file well in March, but after about 4 months doing nothings, it became unbuildable now.

I have researched and followed some, but nothings work at all, include: Running "cordova build android" - unable to find attribute android:fontVariationSettings and android:ttcIndex

$ ionic -v 5.0.3

$ cordova -v 9.0.0 ([email protected])

Using dependencies and plugins: "@ionic-native/brightness": "^4.15.0", "@ionic-native/core": "^4.12.2", "@ionic-native/firebase": "^4.12.0", "@ionic-native/google-maps": "^4.12.0", "@ionic-native/in-app-browser": "^4.12.0", "@ionic-native/splash-screen": "~4.11.0", "@ionic-native/status-bar": "~4.11.0", "@ionic/storage": "2.1.3",

"cordova-android": "7.0.0",
"cordova-plugin-brightness": "^0.2.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-firebase": "^1.1.4",
"cordova-plugin-googlemaps": "^2.4.6",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^2.2.0",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
C:\Users\bb\.gradle\caches\transforms-1\files-1.1\support-compat-27.1.1.aar\3a6ca51037ab15caf4633bd4cbfb4935\res\values\values.xml:20:5-70: AAPT: error: resource android:attr/fontVariationSettings not found.

C:\Users\bb\.gradle\caches\transforms-1\files-1.1\support-compat-27.1.1.aar\3a6ca51037ab15caf4633bd4cbfb4935\res\values\values.xml:20:5-70: AAPT: error: resource android:attr/ttcIndex not found.

C:\Workspace\myproject\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:95: error: resource android:attr/fontVariationSettings not found.
C:\Workspace\myproject\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:95: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
        ...
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
        ... 47 more
Caused by: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        ... 1 more
Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:411)
        at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
        at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt

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

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

BUILD FAILED in 9s
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android exited with exit code 1.
3

3 Answers

1
votes

Try to going to the platform/android folder and edited the project.properties file and replaced com.android.support:support-v4:+ with com.android.support:support-v4:27.1.0.

This is just a quick fix on that issue, you have to find which library do you used throw this error.

0
votes

Change the compileSdkVersion to:

compileSdkVersion 28

fontVariationSettings and ttcIndex were added in api level 28.

0
votes

I followed those guide and fixed my problem. Thank all for supporting. https://stackoverflow.com/a/56748258/11663388

https://stackoverflow.com/a/56719078/11663388

cordova plugin remove cordova-plugin-firebase

cordova plugin add cordova-plugin-firebase-lib

ionic cordova platform rm android

ionic cordova platform add [email protected]

ionic cordova plugin add cordova-plugin-androidx

ionic cordova plugin add cordova-plugin-androidx-adapter