我只是在使用Android 4.3和API 18的三星Galaxy Nexus手机上进行测试时遇到以下错误.
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_error.xml
from drawable resource ID #0x7f020098
at android.content.res.Resources.loadDrawable(Resources.java:2091)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.TextView.<init>(TextView.java:803)
at android.widget.EditText.<init>(EditText.java:60)
Run Code Online (Sandbox Code Playgroud)
在我的Acitivty.java文件中,我尝试使用以下方法设置我的矢量drawable:
editTextNickname.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_error, 0);
editTextNickname.setCompoundDrawables(null, null,
ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_error), null);
Run Code Online (Sandbox Code Playgroud)
我在build.gradle文件中使用了最新的支持库,如下所示:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.peprally.jeremy.peprally"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
repositories {
mavenCentral() …Run Code Online (Sandbox Code Playgroud)