Running “cordova build android” - unable to find a

2019-01-02 20:02发布

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?

24条回答
步步皆殇っ
2楼-- · 2019-01-02 20:47

It's a duplicate entry in values.xml in a folder called support-compat-28.0.0-alpha1.aar.

You'll find this file on Windows at \users\YOURUSERID\.gradle\caches\transforms-1\files-1.1

Once inside that folder you have to go some levels deeper to values.xml.

In that file, search for an element <declare-styleable name="FontFamilyFont>.

In that element, remove the FOUR lines with android: in it.

After I made that change I can build again without errors.

查看更多
回忆,回不去的记忆
3楼-- · 2019-01-02 20:48

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.

查看更多
情到深处是孤独
4楼-- · 2019-01-02 20:48

I had same problem after installing the cordova-plugin-file-opener2 plugin. It resoved after doing: Option 1: Install cordova-android-support-gradle-release plugin. cordova plugin add cordova-android-support-gradle-release --fetch

查看更多
荒废的爱情
5楼-- · 2019-01-02 20:51

SUPER SIMPLE AND CORRECT WAY OF SOLVING IT!

Just update the sdk and add the latest 2 version of android... and restart the computer! Done...

Now we have time to talk about cars and sports...

查看更多
笑指拈花
6楼-- · 2019-01-02 20:52

I was having the same problem out of the blue yesterday. It started randomly, but from reading around, it looks like it is to do with an update as mentioned above by @cpro90. However, I tried and could not find where to make the necessary manual change.

Eventually I identified that the problem was being caused by my cordova-plugin-crosswalk-webview plugin. On GitHub, I found the issue on the plugin repro this morning, and it had over 520 views by lunch.

@UNUMObile suggested the following in the build.gradle file to force an earlier version globally:

configurations.all {
    resolutionStrategy.force 'com.android.support:support-v4:24.0.0'
}

This worked immediately for me and may help others with other plugins that also have had their dependency on 'com.android.support:support-4:<28. The new version 28 seems to be the issue.

I hope this helps someone move forward.

查看更多
宁负流年不负卿
7楼-- · 2019-01-02 20:52

If you are using ionic and you get this error, solve it by doing the following:

-cordova platform rm android
-cordova platform add android

It can be a possible solution

查看更多
登录 后发表回答