yas
yas

Reputation: 519

No resource found that matches the given name:attr 'colorAccent'

I got a bit of issue regarding about the following there.

No resource found that matches the given name: attr 'colorAccent'.

No resource found that matches the given name: attr 'colorPrimary'.

No resource found that matches the given name: attr 'colorPrimaryDark'.

I did a bit of research and most of the post recommend using api level 21. My situation here is software has to support from API level 16.

and the following is my manifest file

   <?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="testproj.com.xxx.testproj">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Base">

    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <activity android:name=".Activity.MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

When I remove

 android:theme="@style/Theme.Base"

Error does not show up but I got black screen on the phone.

This is my gradle (app) file, I am not quite sure I have a correct support file either.

apply plugin: 'com.android.application'

android {
compileSdkVersion 16
buildToolsVersion "23.0.3"
defaultConfig {
    applicationId "testproj.com.xxx.testproj"
    minSdkVersion 16
    targetSdkVersion 18
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

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'
})
//compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:appcompat-v7:20.0.0'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.volley:volley:1.0.0'

}

UPDATED: This is my colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>

styles.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.Base">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

</resources>

Upvotes: 0

Views: 1389

Answers (1)

raasesh
raasesh

Reputation: 161

This is caused when the values are not available in the color file... Could you go to the color file and ensure that these values colorAccent,colorPrimary,colorPrimaryDark are available in that folder..or give your color file code here ...

Upvotes: 0

Related Questions