android - Logcat 警告 :Consider using Resources. getDrawable(int, Theme) 或 Context.getDrawable(int)

标签 android

当我想输入数据但我没有在我的代码中使用任何可绘制对象时,我发现了这个错误。而我只是使用一个简单的 EditText 来读取数据。我在这个论坛中提到了许多其他解决方案,但它没有帮助。

Drawable android:drawable/text_cursor_material has unresolved theme attributes! Consider using Resources.getDrawable(int, Theme) or Context.getDrawable(int).
java.lang.RuntimeException
    at android.content.res.Resources.getDrawable(Resources.java:740)
    at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
    at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
    at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
    at android.widget.Editor$InsertionHandleView.getHotspotX(Editor.java:3772)
    at android.widget.Editor$HandleView.updateDrawable(Editor.java:3399)

编辑(build.gradle)

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion "23.0.2"


defaultConfig {
    applicationId "com.example.user.myapp"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    // Enabling multidex support.
   // multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.2.0'

compile files('libs/org.apache.http.legacy.jar')

compile 'com.android.support:support-v4:23.2.0'
}

最佳答案

总结 issue

  • 使用 ContextCompat.getDrawable(Context, int) 代替 getResources().getDrawable(int)(已弃用)。

  • 如果可用,请使用 0.8.5.7 或更高版本,但不要使用 ma​​terial-dialogs0.8.5.6

关于android - Logcat 警告 :Consider using Resources. getDrawable(int, Theme) 或 Context.getDrawable(int),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36393959/

相关文章:

android - 如何在Android 2.3 GingerBread 中使用 fragment ?

android - 错误 :Failed to complete Gradle execution. 原因:未知

java - 如何以编程方式检测 Android 中是否正在运行任何屏幕录制进程/应用程序?

android - SupportMapFragment vs MapFragment 性能方面

android - ExoPlayer用来自特定站点的URL口吃

android - 如何在android ndk中添加多个共享库?

java - 使用javamail发送邮件抛出错误

java - 登录Facebook App并授权我的应用程序后,如何正确获取Access Token等信息? [安卓]

Android 9-patch 批处理

android - 如何在recyclerview上设置动画