【问题标题】:No resource found that matches the given name: attr android:actionModeShareDrawable even though I'm using appcompat 20找不到与给定名称匹配的资源: attr android:actionModeShareDrawable 即使我使用的是 appcompat 20
【发布时间】:2015-01-31 17:55:29
【问题描述】:

我的应用突然停止编译并显示一堆错误,例如“找不到与给定名称匹配的资源:attr android:actionModeShareDrawable”。

我没有使用 appcompat 21.0.0 或 android 5 sdk,因为 StackOverflow 上的许多答案都建议,并且上周五编译了相同的代码。

唯一不同的是,我现在使用的是 Android Studio RC2。

这是我的 build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/repo' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/repo' }
}


android {
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION


    defaultConfig {
        //noinspection GroovyAssignabilityCheck
        minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
        versionCode 15
        versionName "1.8"
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.release
        }

        debug {
            debuggable true
            applicationIdSuffix ".debug"
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.sothree.slidinguppanel:library:+'
    provided 'com.google.android.gms:play-services:5.0.89'
    compile project(':libraries:ViewPagerIndicator')
    compile files('libs/mobileservices-1.1.5.jar')
    compile files('libs/volley.jar')
    compile files('libs/picasso-2.3.5-SNAPSHOT.jar')
    compile 'com.microsoft.azure.android:azure-storage-android:0.3.1'
    compile 'com.squareup.okhttp:okhttp:2.1.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.1.0@aar') {
        transitive = true;
    }
}

这里是 gradle.properties:

ANDROID_BUILD_MIN_SDK_VERSION=15
ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=20
ANDROID_BUILD_SDK_VERSION=19

我没有引用 Android 5 SDK 或兼容性库 v21,那么为什么我会为这个资源密钥而烦恼呢?

【问题讨论】:

  • 我有同样的问题,当我删除一个模块时发生了。
  • 在没有 android: 的情况下尝试 actionModeShareDrawable 并告诉结果
  • 我没有在我的代码中设置这个。

标签: android


【解决方案1】:

我不知道是什么原因造成的,但我遇到了同样的问题,这个解决方法对我有用:

添加

configurations.all {
    resolutionStrategy {
        force 'com.android.support:appcompat-v7:20.0.0'
    }
}

在 gradle 文件中的 android{} 块下方。

编辑:此错误是由 AndroidSlidingUpPanel 库引起的。 解决方法是将该库包含在您的项目中,如下所示:

compile('com.sothree.slidinguppanel:library:+') {
    exclude group: 'com.android.support', module: 'appcompat-v7'
}

【讨论】:

  • 如何查看我的应用程序依赖项的依赖项?我认为我没有更新我的依赖版本,但由于我没有直接引用 Android 21 中的任何内容,因此找到罪魁祸首的唯一选择是查看我正在使用的库。
  • 我也没有引用 Android 21 中的任何内容。我只是将它包含在我的 app 模块的 build.gradle 中。
  • 我找到了导致错误的依赖,它是来自github.com/umano/AndroidSlidingUpPanel的SlidingUpPanel
  • 啊,这解释了,我也有那个库。我已经更新了我的答案。
  • 我已将编译指令设置为使用2.0.2版本,但感谢您的帮助。
猜你喜欢
  • 2014-12-13
  • 1970-01-01
  • 2014-12-23
  • 2015-05-19
  • 2017-10-13
  • 2018-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多