appcompat-v7 v21.0.0 causing crash on Samsung devices with Android v4.2.2

北城余情 提交于 2019-11-27 17:29:07
robUx4

I found the proper solution here: https://stackoverflow.com/a/26641388/1266123

By using

-keep class !android.support.v7.internal.view.menu.**,android.support.v7.** {*;}

instead of

-keep class android.support.v7.** {*;}

As #150 from https://code.google.com/p/android/issues/detail?id=78377 said

Because careful with -keep class !android.support.v7.internal.view.menu.**. There are a number of classes in there which are referenced from the appcompat's resources.

The better solution is add the following lines instead:

-keep class !android.support.v7.internal.view.menu.MenuBuilder, !android.support.v7.internal.view.menu.SubMenuBuilder, android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

Since Appcompat 23.1.1 the .internal package in the AppCompat jar was removed.

Updated fix using proguard:

#FOR APPCOMPAT 23.1.1:
-keep class !android.support.v7.view.menu.*MenuBuilder*, android.support.v7.** { *; }
-keep interface android.support.v7.* { *; }

For all having this problem, only workaround so far seems to be using proguard. Checkout discussion at https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=78377

If anyone interested in using a solution without progaurd .

Read the link i have tried this in one of my apps which gave the exception on setSupportActionBar(toolbar) in onCreate().

Its pretty simple just add try catch block around the call

try {

 setSupportActionBar(toolbar);

} catch (Throwable t) {

 // WTF SAMSUNG!

}

I encountered the same issue on Tecno P9, but after using build tools 24 and for my support library I used 24.2.0, it was fixed.

Change the Compile Sdk Version of your project to "API 18:(JellyBean)"

The default is set to "Lollipop"

So far it solved my problem on Qmobile i9

STEPS

  1. Right Click on your project and select Open Module Settings (or press F4)
  2. In the properties tab Compiled Sdk Version

Replace AppCompatActivity With Activity

This helped me.

Sachin Waghmare

Replace

public class class_name extends AppCompatActivity
{

.........

}

With

public class class_name extends Activity
{

.........

}

This helped me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!