为什么App Bundle会导致InflateException?

时间:2019-09-30 08:51:16

标签: android inflate-exception

我已经在Google Play上发布了.aab(Android应用捆绑包)文件。当我在VIVO Android 7.0设备上测试.aab时,它显示InflateException。最后,我通过删除xhdpi / dimens.xml解决了它,有人能告诉我为什么会这样吗?

java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package.name/my.package.name.sleeping.SleepingActivity}: android.view.InflateException: Binary XML file line #15: Can't convert value at index 4 to dimension: type=0x1
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2749)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2810)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1531)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6292)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:906)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
     Caused by: android.view.InflateException: Binary XML file line #15: Can't convert value at index 4 to dimension: type=0x1
     Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 4 to dimension: type=0x1
        at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:720)
        at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7404)
        at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1926)
        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1824)
        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1823)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:905)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:906)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:906)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1039)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:899)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:524)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:432)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:383)
        at android.support.v7.app.C.c()
        at android.support.v7.app.m.setContentView()
        at h.a.c.b.a.b.onCreate()
        at my.package.name.sleeping.SleepingActivity.onCreate()
        at android.app.Activity.performCreate(Activity.java:6788)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2810)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1531)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6292)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:906)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)

xhdpi / dimens.xml:

<resources>
    <dimen name="sleeping_activity_image_text_margin_top">32dp</dimen>
</resources>

布局:

...
            <TextView
                android:id="@+id/tip_text"
                android:layout_width="320dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginLeft="0dp"
                android:layout_marginTop="@dimen/sleeping_activity_image_text_margin_top"
                android:layout_marginRight="0dp"
                android:gravity="center"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:text="@string/sleeping_tip_text"
                android:textColor="@color/white_transparent_50"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tip_image" />

0 个答案:

没有答案