user669231
user669231

Reputation: 1369

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

Since past 2 months, we have started receiving native crashes in our developer console only for some Samsung devices.

Here is the crash trace

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/ha3gjv/ha3g:5.0/LRX21V/N9000QXXUEBOG3:user/release-keys'
Revision: '11'
ABI: 'arm'
pid: 10422, tid: 10478, name: AsyncTask #2  >>> com.sample.app <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1c
    r0 131413a0  r1 131413a0  r2 b1687070  r3 00262827
    r4 00000349  r5 131413a0  r6 00000000  r7 00000002
    r8 131412c0  r9 af071800  sl 87783218  fp 13141360
    ip 000031d0  sp 9530e8c0  lr 7446c91f  pc a0a83596  cpsr 000f0030

backtrace:
    #00 pc 001bc596  /data/dalvik-cache/arm/data@[email protected]@[email protected]
    #01 pc 0008091d  /system/framework/arm/boot.oat

And here is the list of devices where crashes have been received till date -

Galaxy S6 (zeroflte)
Galaxy S6 Edge+ (zenltevzw)
Galaxy A5(2016) (a5xelte)
Galaxy S5 Neo (s5neolte)    
Galaxy S6 Edge (zerolte)    
Galaxy S6 (zerofltetmo)
Galaxy Note3 (ha3g)
Galaxy J7 (j7elte)
Galaxy Note4 (trelte)
Galaxy S5 (k3g)
Galaxy Alpha (slte)

Any ideas on why it is happening?

Here is build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.test" 
        minSdkVersion 14
        targetSdkVersion 22
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('libs/okhttp-2.4.0.jar')
    compile files('libs/okhttp-urlconnection-2.4.0.jar')
    compile files('libs/okio-1.4.0.jar')
    compile files('libs/mediaplayersdk.jar')


    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
}

Upvotes: 11

Views: 3164

Answers (2)

Dinesh
Dinesh

Reputation: 482

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.** {*;}

Upvotes: 0

antonio
antonio

Reputation: 18262

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.

Upvotes: 7

Related Questions