2015年12月10日 星期四

Android 在 gradle 中加入 RecyclerView dependency 的錯誤

Android 在 gradle 中加入 RecyclerView dependency 的錯誤

今天要來寫 Android 的 RecyclerView,我在 app.gradle 中的 dependencies 中加入了

compile 'com.android.support:recyclerview-v7:23.1.0'

也就順便把 appcompate-v7 改成一樣的版本

compile 'com.android.support:appcompat-v7:23.1.0'

結果出現了這兩個錯誤

Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

而這兩個東西是在這個檔案裡的

{專案目錄}\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\res\values-v23\values-v23.xml

想想應該是還有哪裡的版本也要改,估狗一下馬上找到原來是 compileSdlVersion 也要設定一樣的版本,再把它改成 23 後就可以正常使用了。

整個 app.gradle 大概是長這樣

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23

    .
    .
    .
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'

    .
    .
    .
}

Written with StackEdit.

沒有留言:

張貼留言