简体   繁体   中英

Android NDK error - Fatal signal 11 (SIGSEGV) Android Studio 3.1.3

I upgraded the Android Studio to 3.1.3 , I also upgraded the ndk from 15 to 17 revision

I changed the below content in the Application.mk from below

APP_ABI := armeabi
APP_PLATFORM := android-17

to

APP_ABI := armeabi-v7a
APP_PLATFORM := android-17

but now I started getting the below error :

  --------- beginning of crash
08-09 14:16:01.783 17582-17582/com.my.app A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x9eed9b60 in tid 17582 (.my.app)
08-09 14:16:01.848 17602-17602/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-09 14:16:01.849 17602-17602/? A/DEBUG: Build fingerprint: 'motorola/potter_n/potter_n:7.0/NPN25.137-67-5/6:user/release-keys'
    Revision: 'p3b0'
    ABI: 'arm'
    pid: 17582, tid: 17582, name: .my.app  >>> com.my.app <<<
    signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x9eed9b60
        r0 00000000  r1 00001000  r2 00000003  r3 00000003
        r4 00001000  r5 00000005  r6 9eed9000  r7 9eed9a28
        r8 a87f6050  r9 be997688  sl a5fb2000  fp be9974e8
        ip 9eed9a28  sp be9974a8  lr 9eed9b60  pc 9eed9b60  cpsr 000f0010
08-09 14:16:01.850 17602-17602/? A/DEBUG: backtrace:
        #00 pc 00000b60  /data/app/com.my.app-1/lib/arm/libmyApp.so (offset 0x5000)

What could be the possible issues. My app uses the native library which is built seperately. Is the NDK building discontinued and build by CMake is supported only?

******UPDATE****************************************************

The native library being used when compiled gives the below error

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:buildNative
Android NDK: The armeabi ABI is no longer supported. Use armeabi-v7a.    
Android NDK: NDK Application 'local' targets unknown ABI(s): armeabi    
Android NDK: Please fix the APP_ABI definition in <location to JNI library sources>/jni/Application.mk    
make: Entering directory `<location to JNI library sources>/jni'
make: Leaving directory `<location to JNI library sources>/jni'
C:<sdk-location>/sdk/ndk-bundle/build//../build/core/setup-app.mk:79: *** Android NDK: Aborting    .  Stop.
:buildNative FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildNative'.
> Process 'command 'C:<sdk-location>\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd'' finished with non-zero exit value 2

build.gradle of the lib is ;

android {
     compileSdkVersion 25
     buildToolsVersion "25.0.0"

     defaultConfig {
         minSdkVersion 18
         targetSdkVersion 21
         versionName  "2"

         ndk {
             moduleName "jniLibrary"
         }
    }
}     

Application.mk as below :

APP_ABI := armeabi
APP_PLATFORM := android-18

Do I have to import my native code to CMake build system?

APP_PLATFORM := android-17

This variable APP_PLATFORM contains the minimum Android platform version you want to support, but it is NOT the NDK version you are using to build your shared libs.

What could be the possible issues. My app uses the native library which is built seperately. Is the NDK building discontinued and build by CMake is supported only?

From the error logs,

08-09 14:16:01.783 17582-17582/com.my.app A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x9eed9b60 in tid 17582 (.my.app)

Your app crashed inside your libc library due to accessing an invalid address. eg null pointer exception. You can investigate your code wherever you have references to the libc functions, eg strlen , strcpy , memcpy , etc.

Android NDK: The armeabi ABI is no longer supported. Use armeabi-v7a.
Android NDK: NDK Application 'local' targets unknown ABI(s): armeabi
Android NDK: Please fix the APP_ABI definition in /jni/Application.mk
make: Entering directory <location to JNI library sources>/jni' make: Leaving directory /jni' C:/sdk/ndk-bundle/build//../build/core/setup-app.mk:79: *** Android NDK: Aborting . Stop. :buildNative FAILED

FAILURE: Build failed with an exception.

armeabi is deprecated in r16 and removed in r17, so you need to use older version of NDK, eg ndk-16b or earlier versions ( https://developer.android.com/ndk/downloads/older_releases ), to build armeabi shared libs.

Do I have to import my native code to CMake build system?

You don't have to. But it is recommended to use CMake instead of ndk-build.

Thanks for the comments. I figured out the cause. I was encrypting the .so formed and the path I have given to the .so was from the armeabi folder . I have already replaced the armeabi to armeabi-v7a in the applicatin.mk but not the folder name in the build,gradle. SIGSEGV can have multiple reasons to occur , this was one of them as the app was linking the old armeabi library instead of armeabi-v7a

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM