Native crashes received in Samsung devices only with Lollipop 5.0 & 5.1 versions

ε祈祈猫儿з 提交于 2019-12-03 11:59:02
antonio

According to Android native crash initiating from /system/framework/arm/boot.oat this error is produced on some Samsung devices when apk is zipaligned using Zopfli.

According to your build.gradle you are using buildToolsVersion "23.0.0" so I would say that your apk is zipaligned using Zopfli and this is the source of the problem that you are finding (Zopfli was added in version 21.0.0).

Note that when you generate your apk using Build -> Generate Signed APK your apk is automatically zipaligned. From the documentation:

zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files

To solve it, you can avoid automatically zipalign adding on zipAlignEnabled false to the release section of your build.gradle:

release {
    //...
    zipAlignEnabled false
}

Then, you need to generate your apk again (you can check that your apk is not zipaligned running zipalign -c -v 4 yourapk.apk. It will output Verification FAILED) and then manually zipalign the apk using the zipalign instructions, avoiding the -z option.

zipalign -f -v 4 yourapk.apk yourzipalignedapk.apk

Other option is to change the buildToolsVersion to, for example 20.0.0 (the zipalign tool in this version doen't include Zopfli) but this is not recommended (From the documentation):

You should always keep your Build Tools component updated by downloading the latest version using the Android SDK Manager. By default, the Android SDK uses the most recent downloaded version of the Build Tools. If your projects depend on older versions of the Build Tools, the SDK Manager allows you to download and maintain separate versions of the tools for use with those projects.

Dinesh

I found the proper solution here. By using

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

instead of

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