我知道我有一个可调试的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,它应该从项目根运行并以某种方式告诉它使用可调试文件?