Running "cordova build android" - unable to find attribute android:fontVariationSettings and android:ttcIndex
Solution 1:
Just put following in build-extras.gradle
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Solution 2:
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.
cordova plugin add cordova-android-support-gradle-release --fetch
Read the documentation for a full set of options: Readme
Option 2: Add next code snippet in build.gradle under platforms/android
/**
IMPORTANT - Manually added
Problem: 8 March 2018 - Google released version support-v4:28.0.0-alpha1
which breaks the project with following error: unable to find attribute
android:fontVariationSettings and android:ttcIndex
Effect: Force a specific version of the library
*/
configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:27.1.0'
}
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:
cordova platform rm android
cordova platform add android
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"
Solution 3:
The same error is happening to me. Apparently, a new version of the com.android.support:support-v4
library was released, and the plugin I'm using defines com.android.support:support-v4:+
as dependency in plugin.xml
. The +
sign means that it will get the latest version (28.0.0), which seems seems to be incompatible with other plugins.
I was able to build a development version by changing all the plugin dependencies from com.android.support:support-v4:+
to com.android.support:support-v4:27.1.0
. Also, I executed ionic cordova platform remove android
and ionic cordova platform add android
. Hope it helps, at least for development.
Solution 4:
I have just fixed this issue by 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
.
Solution 5:
If you really just need a quick fix on that issue to make your build run, you may try adding the following lines into your platforms/android/build.gradle file:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Anyhow, setting the version here is not a sustainable fix.