2016-12-20 92 views
0

我在這方面遇到了一些問題。找不到與指定名稱匹配的資源:attr'colorAccent'

找不到與指定名稱相匹配的資源:attr'colorAccent'。

找不到與指定名稱匹配的資源:attr'colorPrimary'。

找不到與給定名稱匹配的資源:attr'colorPrimaryDark'。

我做了一些調查,大部分崗位的推薦使用API​​級別21 我的情況這裏軟件已經從API級別,支持16

和下面是我的清單文件

<?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> 

當我刪除

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

錯誤沒有顯示,但我手機上有黑屏。

這是我的gradle(app)文件,我不太確定我是否有正確的支持文件。

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' 

}

更新: 這是我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> 
+0

你檢查style.xml文件中的** Theme.Base **? –

+0

請顯示您的款式代碼 –

回答

0

這是當值是n引起沒有可用的顏色文件...你可以去顏色文件,並確保這些值colorAccent,colorPrimary,colorPrimaryDark可在該文件夾..或給你的顏色文件代碼在這裏...

相關問題