java.lang.UnsupportedOperationException:无法将索引 89 处的值转换为维度:type=0x4

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

我的应用程序中发现以下异常。

12-02 11:49:12.640 10039   940   940 E AndroidRuntime: FATAL EXCEPTION: main
12-02 11:49:12.640 10039   940   940 E AndroidRuntime: Process: com.android.service, PID: 940
12-02 11:49:12.640 10039   940   940 E AndroidRuntime: android.view.InflateException: Binary XML file line #8 in com.android.service:layout/item_fg_service: Binary XML file line #8 in com.android.service:layout/item_fg_service: Error inflating class <unknown>
12-02 11:49:12.640 10039   940   940 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #8 in com.android.service:layout/item_fg_service: Error inflating class <unknown>
12-02 11:49:12.640 10039   940   940 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at java.lang.reflect.Constructor.newInstance0(Native Method)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.LayoutInflater.createView(LayoutInflater.java:876)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.LayoutInflater.rInflate(LayoutInflater.java:1145)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at com.android.service.ListAdapter.onCreateViewHolder(ListAdapter.java:55)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at com.android.service.ListAdapter.onCreateViewHolder(ListAdapter.java:26)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:8717)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:7799)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:7683)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:7679)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2476)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1764)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1724)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:746)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:5431)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:5134)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:5727)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.View.layout(View.java:24029)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.layout(ViewGroup.java:6417)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.View.layout(View.java:24029)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.layout(ViewGroup.java:6417)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:346)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.FrameLayout.onLayout(FrameLayout.java:284)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.View.layout(View.java:24029)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.layout(ViewGroup.java:6417)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:346)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.FrameLayout.onLayout(FrameLayout.java:284)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.View.layout(View.java:24029)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.layout(ViewGroup.java:6417)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.View.layout(View.java:24029)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.layout(ViewGroup.java:6417)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:346)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.widget.FrameLayout.onLayout(FrameLayout.java:284)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at com.android.internal.policy.DecorView.onLayout(DecorView.java:797)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.View.layout(View.java:24029)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.layout(ViewGroup.java:6417)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:4110)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3474)
12-02 11:49:12.640 10039   940   940 E AndroidRuntime:  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2420)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9397)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1286)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1294)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.Choreographer.doCallbacks(Choreographer.java:922)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.Choreographer.doFrame(Choreographer.java:855)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1269)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.os.Handler.handleCallback(Handler.java:942)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.os.Handler.dispatchMessage(Handler.java:99)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.os.Looper.loopOnce(Looper.java:201)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.os.Looper.loop(Looper.java:288)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.app.ActivityThread.main(ActivityThread.java:7962)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at java.lang.reflect.Method.invoke(Native Method)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:550)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 89 to dimension: type=0x4, theme={InheritanceMap=[id=0x7f10016dcom.android.service:style/Theme.Transparent, id=0x1030128android:style/Theme.DeviceDefault, id=0x103041fandroid:style/Theme.DeviceDefaultBase, id=0x1030224android:style/Theme.Material, id=0x1030005android:style/Theme], Themes=[com.android.service:style/Theme.Transparent, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]}
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:795)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.View.<init>(View.java:5738)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.<init>(ViewGroup.java:704)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.<init>(ViewGroup.java:700)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at android.view.ViewGroup.<init>(ViewGroup.java:696)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:587)
12-02 11:49:12.641 10039   940   940 E AndroidRuntime:  ... 62 more

该错误很少产生。因此,我无法找出确切的原因并找到解决方案。

我搜索并找到了以下链接,但无法从中得到任何线索:

UnsupportedOperationException:无法转换为维度:类型=0x1 https://issuetracker.google.com/issues/239451099 https://issuetracker.google.com/issues/179692880

https://github.com/SimonVT/android-menudrawer/issues/270 https://github.com/iBotPeaches/Apktool/issues/2684

这是我的 xml 文件。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/container"
        android:layout_width="@dimen/container_width"
        android:layout_height="@dimen/snapshot_height"
        android:paddingHorizontal="@dimen/padding_horizontal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <View
            android:id="@+id/separator"
            android:layout_width="@dimen/separator_width"
            android:layout_height="@dimen/separator_height"
            android:background="#1AFFFFFF"
            android:orientation="vertical"
            android:layout_marginTop="@dimen/snapshot_margin_top"
            android:visibility="invisible"
            android:animateLayoutChanges="true"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent" />

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/item_text"
            style="@style/Widget.AppCompat.Button.Indepth"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="services"
            android:singleLine="false"
            android:maxLines="2"
            android:ellipsize="end"
            android:textAlignment="center"
            android:textColor="#FFFFFFFF"
            android:textSize="17dp"
            android:textAllCaps = "false"
            android:autoSizeTextType="uniform"
            android:layout_marginTop="@dimen/snapshot_margin_top"
            app:layout_constraintStart_toEndOf="@id/separator"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"/>
    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

android android-xml androidx
1个回答
0
投票

我反复查找分析,最后发现明显与尺寸或风格有关。

最后一点,我更准确地重新检查了我的发布分支代码,发现我的成员在挑选开发分支更改时犯了错误。 这是缺少 dp:

<dimen name = "fg_padding_horizontal">7.18</dimen>

而不是

<dimen name = " fg_padding_horizontal">7.18dp</dimen>
© www.soinside.com 2019 - 2024. All rights reserved.