简体   繁体   中英

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_email_black.xml from drawable resource ID #0x7f02007e

When I test it in emulator it is working fine and When to test it in real device Android4.4(19) it is giving this log error I try many alternative solutions but it is not working.

Also add AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); to .Java file.

My Gradle Version is `distributionUrl=https://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip

Here Is my Log error

Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class EditText
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:720)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:762) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    at com.redrockdigimark.doot.activities.OwnerLogin.onCreate(OwnerLogin.java:27)
    at android.app.Activity.performCreate(Activity.java:5442)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493) 
    at android.app.ActivityThread.access$800(ActivityThread.java:166) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5584) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) 
    at dalvik.system.NativeStart.main(Native Method) 
 Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_email_black.xml from drawable resource ID #0x7f02007e
    at android.content.res.Resources.loadDrawable(Resources.java:3451)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:614)
    at android.widget.TextView.<init>(TextView.java:896)
    at android.widget.EditText.<init>(EditText.java:60)
    at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:62)
    at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:58)
    at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112)
    at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1026)
    at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1083)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:762) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:771) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:499) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
    at com.redrockdigimark.doot.activities.OwnerLogin.onCreate(OwnerLogin.java:27) 
    at android.app.Activity.performCreate(Activity.java:5442) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493) 
    at android.app.ActivityThread.access$800(ActivityThread.java:166) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5584) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) 
    at dalvik.system.NativeStart.main(Native Method) 
 Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:969)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:913)
    at android.content.res.Resources.loadDrawable(Resources.java:3447)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:614) 
    at android.widget.TextView.<init>(TextView.java:896) 
    at android.widget.EditText.<init>(EditText.java:60) 
    at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:62) 
    at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:58) 

`

App level gradle:

   apply plugin: 'com.android.application'


android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.redrockdigimark.doot"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true

    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-vector-drawable:26.0.0-alpha1'
    compile 'com.android.support:support-v4:26.0.0-alpha1'
    ------
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

Xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/loginbg"
android:orientation="vertical">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="40dp">
    <EditText
        android:id="@+id/et_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="194dp"
        android:background="@color/white"
        android:drawableStart="@drawable/ic_email_black"
        android:drawablePadding="5dp"
        android:hint="Email"
        android:padding="10dp" />

    <EditText
        android:id="@+id/et_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/et_email"
        android:layout_marginTop="20dp"
        android:background="@color/white"
        android:drawableStart="@drawable/ic_logout"
        android:drawablePadding="5dp"
        android:drawableTint="@color/primary"
        android:hint="Password"
        android:padding="10dp" />


    <TextView
        android:id="@+id/txt_forgot_pwd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_below="@+id/et_password"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="20dp"
        android:text="Forgot Password"
        android:textColor="@color/white" />

</RelativeLayout>

Edit: ic_email_black.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
<path
    android:fillColor="#FFC107"
    android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
</vector>

It shows error on EditText.

 Binary XML file line #11: Error inflating class EditText

Your vector drawable also working fine. Maybe its problem of Android 19 device.

Try using AppcompatEditText instead of EditText

<android.support.v7.widget.AppCompatEditText
        android:id="@+id/et_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="194dp"
        android:background="@color/white"
        android:drawableStart="@drawable/ic_email_black"
        android:drawablePadding="5dp"
        android:hint="Email"
        android:padding="10dp"/>

Hope it helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question how to solve android.content.res.Resources$NotFoundException: File res/drawable/ic_paper_plane.xml from drawable resource ID #0x7f02008f? android.content.res.Resources$NotFoundException: File res/drawable/ic_customer_toolbar.xml from drawable resource ID #0x7f0200d7 Android.Content.Res.Resources+NotFoundException: 'File res/drawable/abc_ic_clear_material.xml from drawable resource ID #0x7f07001d' Exception android.content.res.Resources$NotFoundException: File res/color/selector_tab_blue_white.xml from drawable resource ID #0x7f0601d8 android.content.res.Resources$NotFoundException File res/drawable/$my_app_img__0.xml from color state list resource ID #0x7f07000a Exception android.content.res.Resources$NotFoundException: File res/drawable/my.xml from drawable resource ID Caused by android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID even the resource is there KitKat specific- android.content.res.Resources$NotFoundException: File res/drawable/list_selector_white.xml from drawable resource ID android.content.res.Resources$NotFoundException: Drawable compat_splash_screen_no_icon_background with resource ID #0x7f0801b6 android.content.res.Resources$NotFoundException: Resource ID #0x0 drawable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM