Android Studio 使用Support.v7和support.v4包遇到的各种问题

来源:互联网 发布:sql select 两个字段 编辑:程序博客网 时间:2024/06/05 21:58

使用v7和v4包时会出现这种情况:

/Users/luolawn/Project/AndroidStudioProject/news/ThirdLib/PullToRefreshLibrary/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-v11/values.xml
Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.

v7包中的资源属性不存在,这是由于compileSdkVersion 和buildToolsVersion对应的版本和导入的v7包要求的版本不一样,下面看一个例子:

apply plugin: 'android-library'android {    compileSdkVersion 20    buildToolsVersion "20.0.0"    defaultConfig {        minSdkVersion 15        targetSdkVersion 22        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'        }    }}dependencies {    compile fileTree(dir: '../../Libs', include: ['*.jar'])    compile fileTree(dir: 'libs', include: ['*.jar'])    compile 'com.android.support:support-v4:22.0.0'    compile 'com.android.support:appcompat-v7:22.0.0'    compile 'com.android.support:support-v13:22.0.0'}
我使用的support都是22.0.0版本,然而compileSdkVersion 20,compileToolsVersion 20所以出现了“没有资源属性”错误,解决方法是:

apply plugin: 'android-library'android {    compileSdkVersion 22    buildToolsVersion "22.0.0"    defaultConfig {        minSdkVersion 15        targetSdkVersion 22        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'        }    }}dependencies {    compile fileTree(dir: '../../Libs', include: ['*.jar'])    compile fileTree(dir: 'libs', include: ['*.jar'])    compile 'com.android.support:support-v4:22.0.0'    compile 'com.android.support:appcompat-v7:22.0.0'    compile 'com.android.support:support-v13:22.0.0'}
修改compileSdkVersion 和compileToolsVersion 对应的数据即可

1 0
原创粉丝点击