当前位置: 首页 > 知识库问答 >
问题:

充气异常:二进制XML文件第19行:充气类EditText时出错

蒋英博
2023-03-14
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nuku.mc.august/com.nuku.mc.august.LoginActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class EditText.

这是我的activity_login:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:id="@+id/login_layout"
    android:padding="10dp" >


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical"
        android:paddingLeft="20dp"
        android:paddingRight="20dp" >

        <EditText
            android:id="@+id/email"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:hint="@string/hint_email"
            android:inputType="textEmailAddress"
            android:padding="10dp"
            android:singleLine="true"
            android:textColor="@color/white"
            android:textColorHint="@color/white"
            android:drawableLeft="@drawable/ic_email"
            android:background="@null"/>

        <EditText
            android:id="@+id/password"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:background="@null"
            android:hint="@string/hint_password"
            android:inputType="textPassword"
            android:padding="10dp"
            android:singleLine="true"
            android:drawableLeft="@drawable/ic_lock_icon_png"
            android:textColor="@color/white"
            android:textColorHint="@color/white"
           />

        <!-- Login Button -->

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/btn_login"
            android:layout_width="147dp"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            android:background="@drawable/normal"
            android:textColor="@color/white"
            android:textStyle="bold|italic"
            android:layout_marginTop="24dp"
            android:layout_marginBottom="24dp"
            android:padding="12dp"
            android:text="login"
            android:alpha="0.6"

            />


    </LinearLayout>
</LinearLayout>
            java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nuku.mc.august/com.nuku.mc.august.LoginActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162)
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                                at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                at android.os.Looper.loop(Looper.java:194)
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371)
                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                at java.lang.reflect.Method.invoke(Method.java:525)
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                                at dalvik.system.NativeStart.main(Native Method)
                                                             Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                                                                at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                                                                at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                                                                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                at com.nuku.mc.august.LoginActivity.onCreate(LoginActivity.java:45)
                                                                at android.app.Activity.performCreate(Activity.java:5122)
                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162) 
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                at android.os.Looper.loop(Looper.java:194) 
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                                at dalvik.system.NativeStart.main(Native Method) 
                                                             Caused by: java.lang.reflect.InvocationTargetException
                                                                at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                                                                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                at com.nuku.mc.august.LoginActivity.onCreate(LoginActivity.java:45) 
                                                                at android.app.Activity.performCreate(Activity.java:5122) 
                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162) 
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                at android.os.Looper.loop(Looper.java:194) 
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                                at dalvik.system.NativeStart.main(Native Method) 
                                                             Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02005a a=-1 r=0x7f02005a}
                                                                at android.content.res.Resources.loadDrawable(Resources.java:1967)
                                                                at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
                                                                at android.view.View.<init>(View.java:3338)
                                                                at android.view.ViewGroup.<init>(ViewGroup.java:436)
                                                                at android.widget.LinearLayout.<init>(LinearLayout.java:176)
                                                                at android.widget.LinearLayout.<init>(LinearLayout.java:172)
                                                                at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
                                                                at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
                                                                at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                                                                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                at com.nuku.mc.august.LoginActivity.onCreate(LoginActivity.java:45) 
                                                                at android.app.Activity.performCreate(Activity.java:5122) 
                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162) 
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                at android.os.Looper.loop(Looper.java:194) 
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                                at dalvik.system.NativeStart.main(Native Method) 
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.nuku.mc.august"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:design:23.4.0'

    compile 'com.squareup.retrofit:retrofit:1.9.0'
}

共有1个答案

史鸿运
2023-03-14

问题出在您的android:drawableleft=“@drawable/ic_lock_icon_png”左可抽,右可抽在旧设备中不起作用,所以删除它并检查

如果您想要drawableleft,那么将矢量资产“ic_lock_icon_png”更改为图像资产或JPEG。(重组图像资产)。

 类似资料: