【问题标题】:The error: duplicate value for resource 'attr/fontFamily' with config ''错误:资源“attr/fontFamily”的重复值与配置“”
【发布时间】:2019-08-10 18:54:56
【问题描述】:

在构建项目时,我遇到了这个错误 Android资源编译失败

Android 资源编译失败

E:\Study\Android\Clients Projects\Smupp\Smupp 1.2.1\Smupp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:5397: 错误:资源“attr/fontFamily”与配置“”的重复值。 E:\Study\Android\Clients Projects\Smupp\Smupp 1.2.1\Smupp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:5397: 错误:之前在这里定义的资源。

尝试了所有以前提出的类似问题,但都没有帮助。我被困住了 4 天。

build.gradle(app)
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.28.0'
    }
}

import java.text.SimpleDateFormat

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'com.google.gms.google-services'

android {
    dexOptions {
        jumboMode true
    }
    def versionMajor = 1 // 1 - 20000
    def versionMinor = 2 // 0 - 9
    def versionPatch = 1 // 0 - 99
    def buildNumber = 0 // 0 - 999 used for testing builds, excluded from release versionName
    def appName = "Smupp"
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.smupp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1201001
        versionName "1.2.2"
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        //android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
        resConfigs "en"
        /*javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath false
            }
        }*/
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

    buildToolsVersion '28.0.3'
}

dependencies {
    def supportLibVersion = '1.0.0-beta01'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation "androidx.appcompat:appcompat:1.0.2"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation "androidx.cardview:cardview:1.0.0"
    implementation "com.google.android.material:material:1.1.0-alpha04"
    implementation "androidx.recyclerview:recyclerview:1.1.0-alpha03"
    implementation "androidx.percentlayout:percentlayout:1.0.0"
    implementation 'com.google.android.material:material:1.0.0'

    implementation 'com.google.firebase:firebase-messaging:17.4.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    //implementation "com.google.android.gms:play-services-gcm:16.1.0"

    testImplementation 'junit:junit:4.12'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.squareup.okhttp:okhttp:2.7.5'
    implementation 'com.jakewharton:butterknife:10.1.0'
    implementation 'com.github.johnkil.android-robototextview:robototextview:2.4.3'
    implementation 'com.squareup.retrofit:retrofit:1.9.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.40.0'
    implementation 'com.google.android.exoplayer:exoplayer:r1.5.8'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.googlecode.mp4parser:isoparser:1.1.20'
    implementation('com.twitter.sdk.android:twitter:2.2.0@aar') {
        transitive = true;
    }
}

【问题讨论】:

  • 你用过什么字体
  • 可能你使用的属性名称与 android 系统使用的相同。请检查属性文件并替换该属性。
  • 我也检查过@shizhen
  • 没有像 attrs.xml @MahavirJain 这样的属性文件

标签: java android


【解决方案1】:

看到

values\values.xml:5397: 错误:资源先前在这里定义。

尝试将 fontFamily 名称从 values.xml 重命名。

【讨论】:

  • 没有attrs.xml文件夹
  • 检查values.xml文件。
  • 在 values 文件夹 values.xml 中也不存在
  • 从文件资源管理器我检查了路径并将fontFamily重命名为fontsFamily,但它并没有解决问题。重建项目后,它再次重命名为fontFamily。我认为values.xml 文件是只读的,并在构建/运行项目时重新生成。
  • values.xml 是只读文件,如何建议更改为只读文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-04
  • 1970-01-01
相关资源
最近更新 更多