2

I KNOW I have a debuggable APK and I am running it on the phone based on the following output showing the file being pushed to my phone:

sansari@ubuntu:~/AndroidStudioProjects/Usetbt/app$ ls
app.iml  build  build.gradle  libs  proguard-rules.pro  src
sansari@ubuntu:~/AndroidStudioProjects/Usetbt/app$ adb install ./build/outputs/apk/app-debug.apk 
693 KB/s (1092843 bytes in 1.537s)
    pkg: /data/local/tmp/app-debug.apk
Success

But when I run GDB it complains the apk not being debuggable:

sansari@ubuntu:~/AndroidStudioProjects/Usetbt/app/src/main$ ndk-gdb --verbose 
WARNING: The shell running this script isn't bash.  Although we try to avoid bashism in scripts, things can happen.
/home/sansari/android-ndk-r10e/android-ndk-r10e/ndk-gdb: 214: /home/sansari/android-ndk-r10e/android-ndk-r10e/ndk-gdb: Bad substitution
Android NDK installation path: /home/sansari/android-ndk-r10e/android-ndk-r10e
Using default adb command: /home/sansari/Android/Sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.32
Revision eac51f2bb6a8-android
Using ADB flags: 
Using JDB command: /usr/bin/jdb
Using auto-detected project path: .
Found package name: com.example.sansari.usetbt
ABIs targetted by application: arm64-v8a armeabi armeabi-v7a armeabi-v7a mips mips64 x86 x86_64
Device API Level: 19
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: 
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /home/sansari/android-ndk-r10e/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi
Found debuggable flag: false
ERROR: Package com.example.sansari.usetbt is not debuggable ! You can fix that in two ways:

  - Rebuilt with the NDK_DEBUG=1 option when calling 'ndk-build'.

  - Modify your manifest to set android:debuggable attribute to "true",
    then rebuild normally.

After one of these, re-install to the device!

I think it is because I call gdb from the /main directory of the project, which is the only place GDB seems to start running. And it does not have visibility to the debuggable file, which is off of a different branch of the file structure. Please see below:

../../
├── app.iml
├── build
│   ├── outputs
│   │   ├── apk
│   │   │   ├── app-debug.apk
│   │   │   └── app-debug-unaligned.apk
│   │   └── logs
│   │       └── manifest-merger-debug-report.txt
└── src
    ├── main
    │   ├── AndroidManifest.xml
    │   ├── java
    │   │   └── com
    │   ├── jni
    │   ├── libs
    │   │   └── x86_64
    │   ├── obj
    │   │   └── local
    │   └── res
    │       └── values-w820dp
    └── test
        └── java
            └── com

So the question is how do I run GDB, which should be run from project root and somehow tell it to use the debuggable file?

user3326293
  • 817
  • 1
  • 14
  • 37

0 Answers0