CRASHES& ANRS报告

时间:2016-01-19 03:29:11

标签: android

我是android的新手,我只是推出了我的第一个应用程序。我遇到了以下错误,我很难理解代码中的哪些地方出错了代码中的哪一行崩溃了(我习惯了Log。 d(,""))在此先感谢任何帮助或解释。

java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawableWithShadow
at android.support.v7.widget.CardViewEclairMr1.getShadowBackground(CardViewEclairMr1.java:159)
at android.support.v7.widget.CardViewEclairMr1.getMinWidth(CardViewEclairMr1.java:150)
at android.support.v7.widget.CardView.onMeasure(CardView.java:181)
at android.view.View.measure(View.java:17327)
at android.support.v7.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:6874)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1396)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.support.v4.widget.NestedScrollView.onLayout(NestedScrollView.java:1617)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1156)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15594)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2348)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2061)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6529)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:812)
at android.view.Choreographer.doCallbacks(Choreographer.java:612)
at android.view.Choreographer.doFrame(Choreographer.java:582)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:798)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

编辑:

我正在添加我怀疑的xml: 我认为当它被称为崩溃时,我不确定是什么问题           

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/detail_backdrop_height"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">

        <ImageView
            android:id="@+id/backdrop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="parallax"
            android:transitionName="square"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin" />

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="24dp">



        <android.support.v7.widget.CardView
            android:id="@+id/info_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/card_margin"
            cardUseCompatPadding="true"
            cardCornerRadius="20dp"
            cardElevation="20dp">

            <LinearLayout
                style="@style/Widget.CardContent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/favorite_title"
                    android:textAppearance="@style/TextAppearance.AppCompat.Title" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="@style/TextAppearance.AppCompat.Body1"
                    android:text="@string/favorites_content" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/dialog_pick_county_recycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="475dp"
                    android:layout_margin="0dp"
                    android:transitionName="square2"/>
            </LinearLayout>

        </android.support.v7.widget.CardView>

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>

2 个答案:

答案 0 :(得分:1)

这与您的日志无关。您的某个用户发生了崩溃,并通过Play Developper控制台进行了报告。

在您的代码的某个时刻,您正在尝试将ColorDrawable对象转换为RoundRectDrawableWithShadow,从而导致崩溃。

以下几行为您提供了发生这种情况的地方:

  

在android.support.v7.widget.CardViewEclairMr1.getMinWidth(CardViewEclairMr1.java:150)

如果它不属于您自己的类,您可能会检查您是否没有错误地使用支持库,因为崩溃似乎来自使用android.support.v7.widget包。 / p>

当您使用proguard缩小,混淆或优化时,也会发生这种错误。

答案 1 :(得分:1)

两件事:

一:

myHolder.itemView.setBackgroundColor(Color.SOME_COLOR);更改为((CardView)myHolder.itemView).setCardBackgroundColor(Color.SOME_COLOR);,无论您在哪里使用

二:

我认为您在将应用程序上传到Play商店之前已经对其进行了测试。这意味着错误与发布apk有关。通常,当我们构建一个签名的apk时,ProGuard将尝试缩小包括外部库的代码。那个原因有时会崩溃。

因此,您可以做的是从ProGuard缩小过程中排除所有外部库。找到模块中名为proguard-android.txt的文件。并添加以下内容,

-keep class org.** { *; }
-keep interface org.** { *; }
-keep enum org.** { *; }

这将排除包名称以org开头的所有类/接口/枚举。对所有外部库执行相同操作。再次构建签名发布apk。确保使用签名的apk测试应用程序,而不是调试版。

编辑:

将此添加到您的专业文件

-keep class com.android.** { *; }
-keep interface com.android.** { *; }
-keep enum com.android.** { *; }

-keep class com.github.** { *; }
-keep interface com.github.** { *; }
-keep enum com.github.** { *; }

-keep class com.squareup.** { *; }
-keep interface com.squareup.** { *; }
-keep enum com.squareup.** { *; }

-keep class com.fasterxml.** { *; }
-keep interface com.fasterxml.** { *; }
-keep enum com.fasterxml.** { *; }

-keep class de.hdodenhof.** { *; }
-keep interface de.hdodenhof.** { *; }
-keep enum de.hdodenhof.** { *; }