android.view.InflateException膨胀类<unknown>时出错

时间:2018-07-06 02:03:11

标签: android android-layout android-activity android-manifest android-inflate

我是android的新手,正在构建一个具有情侣活动的应用程序,一个活动用于登录,另一个活动用于与用户交互。关键是我希望登录活动没有标题栏全屏,而另一个活动带有标题栏,但是每次尝试调用登录活动时(全屏无标题栏)我都出错来自主要活动(带有标题栏)。

完整logcat

    07-06 17:53:41.730 23621-23621/? I/art: Late-enabling -Xcheck:jni
07-06 17:53:41.988 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:42.516 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:42.623 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:42.735 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:42.853 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:42.966 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:43.098 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:43.213 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:43.327 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:43.419 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:43.499 23621-23621/com.example.luispaulino.pl W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a7 --instruction-set-features=default --dex-file=/data/app/com.example.luispaulino.pl-2/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.example.luispaulino.pl-2@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
07-06 17:53:43.504 23621-23621/com.example.luispaulino.pl W/System: ClassLoader referenced unknown path: /data/app/com.example.luispaulino.pl-2/lib/arm
07-06 17:53:43.527 23621-23621/com.example.luispaulino.pl I/InstantRun: starting instant run server: is main process
07-06 17:53:43.536 23621-23621/com.example.luispaulino.pl D/FingerprintProtector: No SW version info
07-06 17:53:43.835 23621-23621/com.example.luispaulino.pl W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
07-06 17:53:43.958 23621-23621/com.example.luispaulino.pl D/PhoneWindowEx: [PWEx][generateLayout] setLGNavigationBarColor : colors=0xff000000
07-06 17:53:43.958 23621-23621/com.example.luispaulino.pl I/PhoneWindow: [setLGNavigationBarColor] color=0x ff000000
07-06 17:53:44.061 23621-23621/com.example.luispaulino.pl I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
    Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
07-06 17:53:44.238 23621-23621/com.example.luispaulino.pl D/[AOP]Intent: Intent Private Mode Enable
07-06 17:53:44.238 23621-23621/com.example.luispaulino.pl I/Timeline: Timeline: Activity_launch_request id:com.example.luispaulino.pl time:490107745
07-06 17:53:44.447 23621-23621/com.example.luispaulino.pl D/PhoneWindowEx: [PWEx][generateLayout] setLGNavigationBarColor : colors=0xff000000
07-06 17:53:44.447 23621-23621/com.example.luispaulino.pl I/PhoneWindow: [setLGNavigationBarColor] color=0x ff000000
07-06 17:53:44.463 23621-23621/com.example.luispaulino.pl W/ResourceType: Failure getting entry for 0x7f070063 (t=6 e=99) (error -75)
07-06 17:53:44.466 23621-23621/com.example.luispaulino.pl D/AndroidRuntime: Shutting down VM
07-06 17:53:44.472 23621-23621/com.example.luispaulino.pl E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.luispaulino.pl, PID: 23621
    java.lang.RuntimeException: Unable to start activity ComponentInfo{<Packagename>.pl.LoginActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2440)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500)
        at android.app.ActivityThread.access$900(ActivityThread.java:163)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5585)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
     Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
        at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:467)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at <Packagename>.LoginActivity.onCreate(LoginActivity.java:17)
        at android.app.Activity.performCreate(Activity.java:6279)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
        at android.app.ActivityThread.access$900(ActivityThread.java:163) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5585) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:645)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:467) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at <Packagename>.LoginActivity.onCreate(LoginActivity.java:17) 
        at android.app.Activity.performCreate(Activity.java:6279) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
        at android.app.ActivityThread.access$900(ActivityThread.java:163) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5585) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at android.view.LayoutInflater.createView(LayoutInflater.java:619)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:467) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at <Packagename>.LoginActivity.onCreate(LoginActivity.java:17) 
        at android.app.Activity.performCreate(Activity.java:6279) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
        at android.app.ActivityThread.access$900(ActivityThread.java:163) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5585) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
     Caused by: android.content.res.Resources$NotFoundException: Resource "<Packagename>:drawable/gradient" (7f070063) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070063 a=-1 r=0x7f070063}
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2705)
        at android.content.res.Resources.loadDrawable(Resources.java:2643)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
        at android.view.View.<init>(View.java:3967)
        at android.view.ViewGroup.<init>(ViewGroup.java:574)
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:249)
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:245)
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:241)
        at java.lang.reflect.Constructor.newInstance(Native Method) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:467) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at <Packagename>.LoginActivity.onCreate(LoginActivity.java:17) 
        at android.app.Activity.performCreate(Activity.java:6279) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
        at android.app.ActivityThread.access$900(ActivityThread.java:163) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5585) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 

我的登录活动XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/gradient"
    tools:context=".LoginActivity">


    <ImageView
        android:id="@+id/img"
        android:layout_width="277dp"
        android:layout_height="100dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="114dp"
        app:srcCompat="@drawable/logo" />

    <EditText
        android:id="@+id/fldUser"
        android:layout_width="251dp"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#11000000"
        android:drawableStart="@drawable/ic_action_user"
        android:ems="10"
        android:inputType="textPersonName"
        android:textSize="16sp" />

    <EditText
        android:id="@+id/fldPass"
        android:layout_width="251dp"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="223dp"
        android:background="#11000000"
        android:drawableStart="@drawable/ic_action_key"
        android:ems="10"
        android:inputType="numberPassword"
        android:textSize="16sp" />

    <android.support.v7.widget.CardView
        android:layout_width="300dp"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="118dp"
        app:cardBackgroundColor="@color/colorAccent"
        app:cardCornerRadius="25dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="Entrar"
                android:textColor="#fff" />
        </RelativeLayout>
    </android.support.v7.widget.CardView>
</RelativeLayout>

主要活动XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

</RelativeLayout>

维护

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".LoginActivity"/>
</application>

样式xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

1 个答案:

答案 0 :(得分:1)

问题在于我在drawable文件夹中的背景文件是这样的“ gradient.xml(v24),并且我正在使用v28。我将我的背景文件放入了drawable文件夹中,并且可以正常工作