Android resource linking failed
error: resource android:attr/fontVariationSettings not found.
error: resource android:attr/ttcIndex not found.
error: failed linking references.
我的工程出现这样的错误是由于我引入了recyclerview,而引入了之后,给我的工程带来了库冲突。
我的build.gradle配置如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "28.0.3"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "com.southgis.surver.iData.cadastre"
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a"
}
versionCode 1
versionName "1.0"
}
dexOptions {
javaMaxHeapSize "3g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions{
abortOnError false
}
packagingOptions{
exclude 'META-INF/rxjava.properties'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha1'
implementation 'com.facebook.fresco:fresco:1.7.1'
implementation 'com.android.support:recyclerview-v7:26.1.0'
api 'com.github.bumptech.glide:glide:3.7.0'
api 'com.github.supertaohaili:FileChooser:1.0.9'
}
网上有的解决办法是将compileSdkVersion改为28,但由于改了这个之后对我的工程带来太多的变化,引来更多的问题,而且很多用户的平板的系统还在9.0一下(目前我还没弄清楚compileSdkVersion是否和平板上的android版本有关)。所以我只能另辟蹊径,以下是我的解决方法:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "28.0.3"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "com.southgis.surver.iData.cadastre"
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a"
}
versionCode 1
versionName "1.0"
}
dexOptions {
javaMaxHeapSize "3g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions{
abortOnError false
}
packagingOptions{
exclude 'META-INF/rxjava.properties'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//添加解决策略
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:26.1.0'
}
}
}
这样,便不会出现错误了。