Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug always stripped, never signed #127

Closed
1000283 opened this issue Mar 9, 2021 · 6 comments
Closed

debug always stripped, never signed #127

1000283 opened this issue Mar 9, 2021 · 6 comments

Comments

@1000283
Copy link

1000283 commented Mar 9, 2021

Even if i run build.sh debug the generated apk always has all .so stripped, so no debugging symbols, even if the originals are not stripped.
The gradle strip task always runs.
Moreover, with debug, signing fails due to zipexception so i can't install the apk. (Sometimes i can get around this by unzipping the apk, rm META-INF/CERT.* META-INF/MANIFEST.MF, rezipping and resigning but it doesn't always work.)

e.g., with debug:

> Task :app:stripDebugDebugSymbols
...
jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 17647 but got 16426 bytes)

...without debug:

Stripping libapplication-armeabi-v7a.so by hand
Stripping libapplication-x86.so by hand
Stripping libapplication-x86_64.so by hand
Stripping libapplication-arm64-v8a.so by hand
Copying app data files from project/jni/application/src/AndroidData to project/assets

> Task :app:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :app:stripReleaseDebugSymbols
WARNING: Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.
Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.

BUILD SUCCESSFUL in 37s

If i edit ./project/app/build-template.gradle and add to buildTypes:

    debug {
        applicationIdSuffix ".debug"
        minifyEnabled false
        debuggable true
    }

Then i get this:

Stripping libapplication-armeabi-v7a.so by hand
Stripping libapplication-x86.so by hand
Stripping libapplication-x86_64.so by hand
Stripping libapplication-arm64-v8a.so by hand
Copying app data files from project/jni/application/src/AndroidData to project/assets

> Task :app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/home/myuser/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip: error: '/home/myuser/dev/commandergenius/project/app/build/intermediates/merged_native_libs/debug/out/lib/x86_64/gdb.setup': The file was not recognized as a valid object file

/home/myuser/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip: error: '/home/myuser/dev/commandergenius/project/app/build/intermediates/merged_native_libs/debug/out/lib/x86/gdb.setup': The file was not recognized as a valid object file

/home/myuser/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip: error: '/home/myuser/dev/commandergenius/project/app/build/intermediates/merged_native_libs/debug/out/lib/arm64-v8a/gdb.setup': The file was not recognized as a valid object file

/home/myuser/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip: error: '/home/myuser/dev/commandergenius/project/app/build/intermediates/merged_native_libs/debug/out/lib/armeabi-v7a/gdb.setup': The file was not recognized as a valid object file


> Task :app:stripDebugDebugSymbols
WARNING: Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.
Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.
Unable to strip the following libraries, packaging them as they are: gdb.setup.

BUILD SUCCESSFUL in 9s

But still stripped even project/app/build/outputs/apk/debug/app-debug.apk
How can i reliably buid an apk with not stripped .so libs in it?

Regardless of configuration, tweaks, edits and what not, whenever i get a crash, this is it:

    --------- beginning of crash
2021-03-09 15:09:08.055 7518-7556/com.my.app.debug A/libc: Fatal signal 7 (SIGBUS), code 1, fault addr 0x891183ce in tid 7556 (SDLVideoThread)
2021-03-09 15:09:08.129 7563-7563/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2021-03-09 15:09:08.129 7563-7563/? A/DEBUG: Build fingerprint: 'alps/full_rlk6580_we_c_m/rlk6580_we_c_m:7.1.2/N2G47H/185:user/release-keys'
2021-03-09 15:09:08.129 7563-7563/? A/DEBUG: Revision: '0'
2021-03-09 15:09:08.129 7563-7563/? A/DEBUG: ABI: 'arm'
2021-03-09 15:09:08.130 7563-7563/? A/DEBUG: pid: 7518, tid: 7556, name: SDLVideoThread  >>> com.my.app.debug <<<
2021-03-09 15:09:08.130 7563-7563/? A/DEBUG: signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x891183ce
2021-03-09 15:09:08.131 7563-7563/? A/DEBUG:     r0 89047d00  r1 00000081  r2 5be2c706  r3 00000000
2021-03-09 15:09:08.131 7563-7563/? A/DEBUG:     r4 00000080  r5 0000007e  r6 891183ce  r7 89f96d40
2021-03-09 15:09:08.131 7563-7563/? A/DEBUG:     r8 89047980  r9 00000001  sl 00000000  fp 89f96d70
2021-03-09 15:09:08.131 7563-7563/? A/DEBUG:     ip a79dc860  sp 89f96d30  lr a79ac2c9  pc 8b134924  cpsr 000f0030
2021-03-09 15:09:08.140 7563-7563/? A/DEBUG: backtrace:
2021-03-09 15:09:08.140 7563-7563/? A/DEBUG:     #00 pc 00079924  /data/app/com.my.app.debug-2/lib/arm/libc++_shared.so (_ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcj+47)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #01 pc 000798ed  /data/app/com.my.app.debug-2/lib/arm/libc++_shared.so (_ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_+28)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #02 pc 005f21ec  /data/app/com.my.app.debug-2/lib/arm/libapplication.so
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #03 pc 005f7aac  /data/app/com.my.app.debug-2/lib/arm/libapplication.so
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #04 pc 005f78d4  /data/app/com.my.app.debug-2/lib/arm/libapplication.so
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #05 pc 005ef64c  /data/app/com.my.app.debug-2/lib/arm/libapplication.so
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #06 pc 004d11f1  /data/app/com.my.app.debug-2/lib/arm/libapplication.so (_Z20Send_Callback_ResultPc+24)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #07 pc 004d1283  /data/app/com.my.app.debug-2/lib/arm/libapplication.so (_Z9send_pageP14MHD_ConnectionPKci+22)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #08 pc 004c5b87  /data/app/com.my.app.debug-2/lib/arm/libapplication.so (_Z14ManageCallbackP14MHD_ConnectioniiPci+1178)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #09 pc 00456663  /data/app/com.my.app.debug-2/lib/arm/libapplication.so (_Z16FE_Send_CallbackPviii+90)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #10 pc 00496697  /data/app/com.my.app.debug-2/lib/arm/libapplication.so (_Z7fe_mainiPA11_c+6678)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #11 pc 002b7c1b  /data/app/com.my.app.debug-2/lib/arm/libapplication.so (SDL_main+13458)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #12 pc 00000ccb  /data/app/com.my.app.debug-2/lib/arm/libsdl_main.so (Java_com_DemoRenderer_nativeInit+750)
2021-03-09 15:09:08.141 7563-7563/? A/DEBUG:     #13 pc 00271d43  /data/app/com.my.app.debug-2/oat/arm/base.odex (offset 0x24c000)

From the log the app seems to run fine until this. The previous lines are usually these:

2021-03-09 15:09:06.718 7518-7556/com.my.app.debug I/my_log: a log message from my app
2021-03-09 15:09:06.780 7518-7556/com.my.app.debug V/libSDL: calling SDL_SetVideoMode(1280, 800, 16, 16)
2021-03-09 15:09:06.780 7518-7556/com.my.app.debug I/libSDL: SDL_SetVideoMode(): application requested mode 1280x800 OpenGL 0 HW 0 BPP 16
2021-03-09 15:09:06.780 7518-7556/com.my.app.debug E/libSDL: ERROR: Setting the swap interval is not supported
2021-03-09 15:09:06.780 7518-7556/com.my.app.debug E/libSDL: ERROR: Getting the swap interval is not supported
2021-03-09 15:09:06.780 7518-7556/com.my.app.debug E/libSDL: ERROR: GL_GetAttribute not supported
2021-03-09 15:09:06.786 7518-7556/com.my.app.debug V/libSDL: SDL_SetVideoMode(): Requested mode: 1280x800x16, obtained mode 1280x800x16
2021-03-09 15:09:06.786 7518-7556/com.my.app.debug V/libSDL: SDL_SetVideoMode(): returning surface 0x89048780
2021-03-09 15:09:06.786 7518-7556/com.my.app.debug E/libSDL: ERROR: SDL_RWFromFile(): No file or no mode specified
2021-03-09 15:09:06.786 7518-7556/com.my.app.debug E/libSDL: ERROR: SDL_RWFromFile(): No file or no mode specified

Something related with video, yet on my app. When i get something useful out of Android Studio it tells me, on a debug run:
SIGBUS (signal SIGBUS: illegal alignment)

I find it odd that the path is .../arm/... as this is running on an arm64 device (with litters the logs with logs of error messages of other components - such as NFC not connecting).

@pelya
Copy link
Owner

pelya commented Mar 9, 2021 via email

@1000283
Copy link
Author

1000283 commented Mar 9, 2021

Thanks for replying.
I'm not interested in the Play Store (maybe later).

This .aab that is generated seems like a trimmed down / pre-packaging version of the .apk, and is not recognized by Android Studio.
Also, if i file base/lib/x86/*.so, for example, all files are still stripped.

I don't tihnk i can just adb install the .aab onto a device as-is, right? Do i need to run something like aapt over the contents so i can get a debug apk i can install onto a device?

Maybe mv manifest/* . mv dex/* ., then sign and zip?

@pelya
Copy link
Owner

pelya commented Mar 9, 2021 via email

@1000283
Copy link
Author

1000283 commented Mar 10, 2021

The stack trace pertains to the stripped/release version of the lib.

I got useful information with $NDK/prebuilt/linux-x86_64/bin/gdb $PWD/project/obj/local/arm64-v8a/libapplication.so -ex "list *0x004c5bb7" -ex "list *0x004966c7" , because the version in obj/local is the only one that's non-stripped/debug.

I'm not versed on the ELF file format; is the information provided by gdb on the non-stripped version of the lib accurate? I.e. does it match the stripped version the stack trace provides?

@pelya
Copy link
Owner

pelya commented Mar 10, 2021 via email

@1000283 1000283 closed this as completed Mar 10, 2021
@1000283
Copy link
Author

1000283 commented Mar 10, 2021

A slight heads-up.

I find it odd that the path is .../arm/... as this is running on an arm64 device (with litters the logs with logs of error messages of other components - such as NFC not connecting).

The Cortex-A53 is an armv8-a CPU, which means it also runs 32bits.

After adb pulling the libs from /data/app/com.my.app/lib/arm (there were no other directories at this level), file told me these are all ELF 32-bit LSB shared object, ARM, EABI5 version 1, so in fact armeabi-v7a.

The output that gdb and ndk-stack were giving me was rather confusing as it didn't seem to match the stack trace from logcat. It wasn't until i switched the lib to the arm32 version that it began making sense.

For completeness:

$NDK/prebuilt/linux-x86_64/bin/gdb $PWD/project/obj/local/armeabi-v7a/libapplication.so \
-ex "list *0x00079924" \
-ex "list *0x000798ed" \
..
$NDK/ndk-stack -sym $PWD/project/obj/local/armeabi-v7a -i /my/logcat.txt > /my/logcat.dump

...and not arm64-v8a (in my case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants