When I run cordova build android --buildConfig xxxx --release
,
I get the following error:
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
The strange thing is I use two macOS machines for the compilation, and I get this error only on one of them for the same code.
Here is the output of ./gradlew cdvPrintProps
I get on the two machines:
:cdvPrintProps
cdvCompileSdkVersion=26
cdvBuildToolsVersion=27.0.3
cdvVersionCode=null
cdvMinSdkVersion=21
cdvBuildMultipleApks=true
cdvReleaseSigningPropertiesFile=release-signing.properties
cdvDebugSigningPropertiesFile=null
cdvBuildArch=null
computedVersionCode=152045989
computedArmv7VersionCode=1520459892
computedX86VersionCode=1520459894
Below is the list of plugins used:
$ cordova plugins list
cordova-custom-config 5.0.2 "cordova-custom-config"
cordova-fabric-plugin 1.1.10 "cordova-fabric-plugin"
cordova-open-native-settings 1.5.0 "Native settings"
cordova-plugin-app-event 1.2.1 "Application Events"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-crosswalk-webview 2.4.0 "Crosswalk WebView Engine"
cordova-plugin-datepicker 0.9.2 "DatePicker"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-email 1.2.7 "EmailComposer"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-inappbrowser 1.7.2 "InAppBrowser"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-secure-storage 2.6.8 "SecureStorage"
cordova-plugin-splashscreen 4.1.0 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova.plugins.diagnostic 3.9.2 "Diagnostic"
de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification"
ionic-plugin-keyboard 2.2.1 "Keyboard"
How can I fix this problem?
I had the same problem, and none of the given solutions worked for me. Installing the latest version of Android SDK Build-tools (27.0.3) resolved my problem.
Google released the new version 28.0.0-alpha1 of com.android.support:support-v4 which is adding 2 new attributes(android:fontVariationSettings and android:ttcIndex). Some of the plugins are using the latest android-support libraries which results in unwanted incompatibilities.
Option 1: Install cordova-android-support-gradle-release plugin.
Well documented plugin which "aligns various versions of the Android Support libraries specified by other plugins to a specific version". Tested without any destructive behavior.
Read the documentation for a full set of options: Readme
Option 2: Add next code snippet in build.gradle under platforms/android
Warning: code in build.gradle will be overwritten if you remove/add the Android platform. If you don't want to use the plugin for some reason or somehow is not working for you, instead create a hook and overwrite the file every time. Check 2nd comment here.
If the problem is persistent you may try:
OR
Make sure you don't have a previous version of the app installed on the device you test because you'll receive an ambiguous error when it tries to downgrade the existing version: "INSTALL_FAILED_VERSION_DOWNGRADE" and "UnhandledPromiseRejectionWarning: Unhandled promise rejection"
Some of your libraries should be using
Find which one that is, with
And add that library as a module if it is not using a specific version in it's latest update (Also raise an issue in that library! ;) )
Thanks to @avmatte!
updates to @Brad Pitcher's answer:
hooks/copy_build_extras.js
config.xml
build-extras.gradle
in the root dirAnother aproach with same solution is create a hook. It's persistent (after platform reinstall), you can commit it and it don't require re-adding platform.
Init hook in config
Install fs dependency to your project:
Run build:
I was facing the same error. Did a complete research in the plugin-directory for com.android.support:support-v4:+ and replaced it with a static version code.
For me, com.android.support:support-v4:23.4.0 worked just fine. There was no need to remove and re-add the android platform then.