有时,我的应用程序在API 28定位到目标后,就会由于android.view.InflateException崩溃

时间:2018-10-22 17:09:43

标签: android

将我的应用程序定位为api 28之后,Fabric会向我显示一些崩溃消息:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mydomain.myapp/com.mydomain.myapp.SplashScreen}: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2330)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
   at android.app.ActivityThread.access$800(ActivityThread.java:156)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5278)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Caused by android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
   at android.view.LayoutInflater.createView(LayoutInflater.java:633)
   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
   at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
   at base.activity.BaseSplash.onCreate(BaseSplash.java:149)
   at com.mydomain.myapp.SplashScreen.onCreate(SplashScreen.java:77)

在各种设备中和启动屏幕中,但只有不到0.1%的用户使用。在定位API 28之前,我没有这个错误。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bckgrnd_splash">

<View
    android:id="@+id/grass"
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:background="@color/grass"
    android:layout_alignParentBottom="true"/>

<View
    android:background="@drawable/grass"
    android:layout_width="wrap_content"
    android:layout_height="48dp"
    android:id="@+id/grassImage"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" />

<View
    android:background="@drawable/road_bckgrnd"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:id="@+id/roadView"
    android:layout_above="@+id/grass"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<View
    android:background="@color/grassRoad"
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:id="@+id/topRoadView"
    android:layout_above="@+id/roadView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<View
    android:id="@+id/buildins"
    android:background="@drawable/buildings_cloud"
    android:layout_width="match_parent"
    android:layout_height="138dp"
    android:layout_above="@+id/topRoadView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<ImageView
    android:paddingTop="20dp"
    android:src="@drawable/splash_bus_sitp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/grassImage"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="30dp"
    android:id="@+id/sitpImage" />

<ImageView
    android:id="@+id/taxiImage"
    android:src="@drawable/splash_taxi"
    android:layout_above="@id/grass"
    android:layout_alignParentRight="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="20dp"/>

<ImageView
    android:id="@+id/tmImage"
    android:src="@drawable/splash_bus_tm"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="12dp"
    android:layout_above="@+id/grassImage"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<ImageView
    android:id="@+id/cloudLeft"
    android:layout_marginTop="32dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:src="@drawable/splash_cloud_left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<ImageView
    android:id="@+id/logo"
    android:layout_marginTop="48dp"
    android:layout_below="@id/cloudLeft"
    android:src="@drawable/splash_logo"
    android:layout_centerHorizontal="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<ImageView
    android:layout_marginTop="32dp"
    android:layout_below="@id/logo"
    android:layout_alignParentRight="true"
    android:src="@drawable/splash_cloud_right"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</RelativeLayout>

有人可以帮助我解决这个问题吗?或对此有所了解?第14行是第二个视图。

感谢您的帮助。

0 个答案:

没有答案