私はデバッグ可能な APK を持っていることを知っており、ファイルが自分の電話にプッシュされていることを示す次の出力に基づいて、電話で実行しています。
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
しかし、GDB を実行すると、apk がデバッグ可能ではないというエラーが表示されます。
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!
これは、プロジェクトの /main ディレクトリから gdb を呼び出すためだと思います。これは、GDB が実行を開始する唯一の場所です。また、ファイル構造の別のブランチから離れているデバッグ可能なファイルは表示されません。下記を参照してください:
../../
├── 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
問題は、プロジェクトのルートから実行し、デバッグ可能なファイルを使用するように指示する必要がある GDB をどのように実行するかです。