有一個(gè)遺留的項(xiàng)目,大概半年沒(méi)維護(hù)了,今天要修改個(gè)地方,發(fā)現(xiàn)編譯不過(guò)了:
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
這種In <declare-styleable> FontFamilyFont之類(lèi)的問(wèn)題,google上主要說(shuō)是compileSdkVersion和buildToolsVersion版本太低的問(wèn)題,試了無(wú)效。然后stackoverflow一個(gè)帖子提到是support-v4更新了之后才有的問(wèn)題。
于是在運(yùn)行命令gradle -q dependencies查看依賴(lài):

image.png
果然,crosswalk依賴(lài)了v4包,而且是很低的版本,但是現(xiàn)在v4包已經(jīng)更新28。所以我們要強(qiáng)制指定代碼里面的v4包到一個(gè)比較低的版本,比如23。
在build.gradle中加入以下:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:23.1.0'
}
}
此時(shí)再運(yùn)行gradle -q dependencies:

image.png
可見(jiàn)v4的包已經(jīng)固定在我們指定的版本了。
然后編譯,通過(guò)~