0

I am developing android app. I want to change the color of status text. It is also known textColorPrimary. But shows the error.

Error:(829, 21) No resource found that matches the given name: attr 'textColorPrimary'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

My codes shown below.

AndroidManifest.xml

        <activity
        android:name=".home.HomeActivity"
        android:theme="@style/AppTheme.GrayStatusBar"/>

values\styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.GrayStatusBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimaryDark">@color/colorGray</item>
    <item name="textColorPrimary">@color/bg</item>
</style>
</resources>

v21\styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>

v17\styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>

build.gradle

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    sourceSets.main {
        jniLibs.srcDir 'libs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }

    android {
        useLibrary 'org.apache.http.legacy'
    }
    defaultConfig {
    applicationId "com.acs.udial"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 15770
    versionName "r15770"
    testApplicationId "com.test"
    testInstrumentationRunner "android.test.InstrumentationTestRunner"
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

lintOptions {
    abortOnError false
}
}

    allprojects {
    repositories {
    maven { url "https://jitpack.io" }
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
}

How to solve my problem? please help me?

joe
  • 55
  • 2
  • 9

3 Answers3

1

The problem solved by change the theme parent to parent="Theme.AppCompat.Light". So now the style.xml is

<style name="AppTheme.GrayStatusBar" parent="Theme.AppCompat.Light">
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorPrimary">@color/colorPrimaryDark</item>
    <item name="android:textColor">@color/textColorPrimary</item>

</style>
joe
  • 55
  • 2
  • 9
0

Because you forgot to specify android for textColorPrimary and textColorSecondary. please check code below:

<style name="ToolbarThemeDemo" parent="Theme.AppCompat.Light">
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:textColorSecondary">@android:color/white</item>
</style>
mlapaglia
  • 852
  • 14
  • 31
-1

In your values folder there should be a colors.xml file that defines your textColorPrimary color, e.g.:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="textColorPrimary">#ff004080</color>
</resources>

Replace #ff004080 with the ARGB code of your color of choice.

souty
  • 607
  • 3
  • 10