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:53

It's strange, but it works when I add the below lines with the same versions.

This is my related lines in the platforms/android/build.gradle file:

dependencies {
  compile fileTree(dir: 'libs', include: '*.jar')
  // SUB-PROJECT DEPENDENCIES START
  debugCompile(project(path: "CordovaLib", configuration: "debug"))
  releaseCompile(project(path: "CordovaLib", configuration: "release"))
  compile "com.android.support:support-v4:26.+"
  compile "com.android.support:appcompat-v7:26.+"
  // SUB-PROJECT DEPENDENCIES END
}

// ADDED THESE LINES
configurations.all {
  resolutionStrategy.force 'com.android.support:support-v4:26+'
}

In my project, the problem was occurred because of the 'cordova-plugin-crosswalk-webview' plugin.

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

In your build.gradle file add

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

And in your project.properties file change cordova.system.library.3 to cordova.system.library.3=com.android.support:support-v13:27.+.

查看更多
何处买醉
4楼-- · 2019-01-02 20:58

For Phonegap Build users, as @catu mentionned in a comment, you can try this plugin which purpose is to prevent build failures caused by including different versions of the support libraries.

查看更多
倾城一夜雪
5楼-- · 2019-01-02 21:00

I have the same error but not in cordova build. A new version of the com.android.support:appcompat-v7 and dependencies.But the incompatible version is in the third package that dependent on com.android.support:appcompat-v7.So i can't fixed the third package with @avmatte's solution.

Use @Sai Teja's solution to find incompatible package:

gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath

Then fixed it with:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-compat:{the_same_version}'
        force 'com.android.support:appcompat-v7:{the_same_version}'
        force 'com.android.support:support-core-utils:{the_same_version}'
        force 'com.android.support:support-core-ui:{the_same_version}'
        force 'com.android.support:support-fragment:{the_same_version}'
        force 'com.android.support:support-annotations:{the_same_version}'
        ...
    }
}

Above code force the dependencies version.

查看更多
梦该遗忘
6楼-- · 2019-01-02 21:00

Just some tips for Kotlin developer:

If you follow these answers here, you are sure you don't have support-v4 library in your project but you are still seeing this error, please take a look at the ktx library.

I just figure out that I am using the latest 1.0.0-alpha1 version for ktx library and this error show out; after I changed back to version 0.3, everything back to normal now.

查看更多
不再属于我。
7楼-- · 2019-01-02 21:00

Solution link

This is due to compat plugin. Remove that plugin if you have older version (less than 1.2.0) and set cordova-android@6.3.0

cordova plugin rm cordova-plugin-compat --force

cordova plugin add cordova-plugin-compat@1.2.0

cordova platform rm android

ionic cordova platform add android@6.3.0

Working at my case. Thanks :)

查看更多
登录 后发表回答