二进制XML文件第2行:膨胀类android.widget.RelativeLayout的错误

问题描述 投票:-1回答:1

请任何优秀的android开发人员帮助我解决此问题

这里发生的问题:

android:background="@drawable/splash_bg"

splash_bg是矢量图像

而我的sdk目标是28如果我删除此((android:background =“ @ drawable / splash_bg”)),则代码通过此传递,然后定义了任何其他活动的背景,并给出错误:

我尝试过:

1)检查所有xml图像是否处于可绘制状态,而不是位于* -v24中

2)splash_bg的大小

但似乎没有任何工作可以解决此问题

请请帮助我解决此问题,非常感谢。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:background="@drawable/splash_bg"

    android:id="@+id/vSplash"

    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_margin="60dp"
        android:layout_alignParentStart="true">

<!--        <ImageView
            android:id="@+id/ivbelowLogo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dp"
            android:layout_marginTop="30dp"
            android:layout_marginStart="30dp"
            android:layout_marginEnd="30dp"
            android:layout_weight="0"
            android:layout_alignParentTop="true"
            android:adjustViewBounds="true"
            android:src="@drawable/splash_zayed_big" />-->

        <ImageView android:id="@+id/ivSplash"
            android:layout_width="match_parent"
            android:layout_weight="4"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:src="@drawable/splash_logo"
            android:layout_gravity="center"/>

        <ImageView android:id="@+id/ivSplashGif"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:src="@drawable/splash_loading"
            android:layout_gravity="center"/>


    </LinearLayout>


    <RelativeLayout
        android:id="@+id/versionLayout"
        android:layout_width="wrap_content"
        android:layoutDirection="ltr"
        android:layout_marginBottom="10dp"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:layout_height="wrap_content">

        <TextView android:id="@+id/tvVersion"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:textColor="@color/white"
            android:textSize="12dp"
            android:text="@string/version_name"/>

        <!--<TextView android:id="@+id/tvPowered"-->
            <!--android:layout_below="@id/tvVersion"-->
            <!--android:textSize="12dp"-->
            <!--android:layout_centerVertical="true"-->
            <!--android:layout_width="wrap_content"-->
            <!--android:layout_height="wrap_content"-->
            <!--android:text="@string/beta_version" />-->

    </RelativeLayout>

</RelativeLayout>

除少数设备崩溃外,在所有设备上均可正常运行。

这是问题:

android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout

E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{ae.abc.xyzapp/ae.abc.xyzapp.ui.InitActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
        at android.app.ActivityThread.access$800(ActivityThread.java:135)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5001)
        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:785)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
        at android.view.LayoutInflater.createView(LayoutInflater.java:620)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at android.app.Activity.performCreate(Activity.java:5231)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
        at android.app.ActivityThread.access$800(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5001) 
        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:785) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
        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:423)
        at android.view.LayoutInflater.createView(LayoutInflater.java:594)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at ae.mazadat.onlineauctionapp.ui.InitActivity.onCreate(InitActivity.java:87) 
        at android.app.Activity.performCreate(Activity.java:5231) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
        at android.app.ActivityThread.access$800(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5001) 
        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:785) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
        at dalvik.system.NativeStart.main(Native Method) 
     Caused by: android.content.res.Resources$NotFoundException: File res/drawable/splash_bg.xml from drawable resource ID #0x7f080216
        at android.content.res.Resources.loadDrawable(Resources.java:2096)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
        at android.view.View.<init>(View.java:3554)
        at android.view.View.<init>(View.java:3484)
        at android.view.ViewGroup.<init>(ViewGroup.java:464)
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:236)
        at java.lang.reflect.Constructor.constructNative(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at ae.mazadat.onlineauctionapp.ui.InitActivity.onCreate(InitActivity.java:87) 
        at android.app.Activity.performCreate(Activity.java:5231) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
        at android.app.ActivityThread.access$800(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5001) 
        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:785) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
        at dalvik.system.NativeStart.main(Native Method) 
     Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag vector
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
        at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
        at android.content.res.Resources.loadDrawable(Resources.java:2092)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 
        at android.view.View.<init>(View.java:3554) 
        at android.view.View.<init>(View.java:3484) 
        at android.view.ViewGroup.<init>(ViewGroup.java:464) 
        at android.widget.RelativeLayout.<init>(RelativeLayout.java:236) 
        at java.lang.reflect.Constructor.constructNative(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at ae.mazadat.onlineauctionapp.ui.InitActivity.onCreate(InitActivity.java:87) 
        at android.app.Activity.performCreate(Activity.java:5231) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
        at android.app.ActivityThread.access$800(ActivityThread.java:135) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:136) 
        at android.app.ActivityThread.main(ActivityThread.java:5001) 
        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:785) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
        at dalvik.system.NativeStart.main(Native Method)

[请任何优秀的android开发人员帮助我解决这里发生的问题:android:background =“ @ drawable / splash_bg” splash_bg是矢量图像,如果我删除此SDK,则我的sdk目标是28(...

android android-studio android-activity android-inflate
1个回答
0
投票

仅在设备运行Android> = 5.X.X时有效。引入了对矢量可绘制对象的支持。

© www.soinside.com 2019 - 2024. All rights reserved.