【问题标题】:String types not allowed (at 'blue' with value '')不允许使用字符串类型(在“蓝色”处,值为“”)
【发布时间】:2016-05-01 15:18:01
【问题描述】:

我在构建项目的 appcompat-v7 库中遇到以下错误。

    Error:(380, 5) String types not allowed (at 'blue' with value '').
\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\res\values\values.xml

出现此错误的appcompat-v7 library values.xml文件:

   <!-- this line --> <style name="Base.TextAppearance.AppCompat.SearchResult" parent=""> 



<item name="android:textStyle">normal</item>
                <item name="android:textColor">?android:textColorPrimary</item>
                <item name="android:textColorHint">?android:textColorHint</item>
            </style>

我有最新版本的 Android Studio(2.0 Preview 7)和 appcompat-v7 库。

build.gradle:

apply plugin: 'com.android.model.application'
model {
    android {
        compileSdkVersion  23
        buildToolsVersion "23.0.2"

        defaultConfig.with {
            applicationId "com.ms.sensors"
            minSdkVersion.apiLevel 7
            targetSdkVersion.apiLevel 23
            versionCode 1
            versionName "1.0"
        }

        compileOptions.with {
            sourceCompatibility = JavaVersion.VERSION_1_7
            targetCompatibility = JavaVersion.VERSION_1_7
        }

        buildTypes {
            release {
                minifyEnabled = false
                proguardFiles.add(file('proguard-rules.txt'))
            }
        }
    }

    android.ndk {
        moduleName = "sensorgraph"
        cppFlags.add("-Werror")
        ldLibs.addAll(["log", "GLESv2", "android"])
        stl = "c++_static"
    }

    android.productFlavors {
        create("arm7") {
            ndk.abiFilters.add("armeabi-v7a")
        }
        create("arm8") {
            ndk.abiFilters.add("arm64-v8a")
        }
        create("x86-32") {
            ndk.abiFilters.add("x86")
        }
        // for detailed abiFilter descriptions, refer to "Supported ABIs" @
        // https://developer.android.com/ndk/guides/abis.html#sa

        // build one including all cpu architectures
        create("all")
    }
}
dependencies {
    //        compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
}

我的 style.xml:

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

【问题讨论】:

  • 发布您的values.xml 文件
  • @UmaKanth 你的意思是来自 v7 库的 xml 文件吗?
  • 我没有修改它。该文件位于 build 文件夹下,我每次在 build 期间自动生成。
  • 我什至尝试清理项目并重建它。
  • 你能把你的styles.xml贴在这里吗?我遇到了同样的问题,问题出在styles.xml

标签: android build android-support-library android-build


【解决方案1】:

您将空值分配给“蓝色”

打开您的 color.xml,然后搜索“蓝色”并检查您指定的颜色

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="blue"></color> <!-- must add valid value -->
</resources>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多