Я пытаюсь выполнить отладку собственного кода на моем HTC Desire для моего проекта Android. Проект состоит из тонкого слоя оболочки JNI и основного блока на C ++, скомпилированного с помощью ndk-build. Флаг отладки установлен, я запускаю 2.2 на HTC Desire и работаю с Ubuntu на моем ПК.
Итак, простой ndk-gdb --start возвращает:
ERROR: Could not setup network redirection to gdbserver?
Maybe using --port= to use a different TCP port might help?
Это странно. Я проверил в Интернете и обнаружил, что это неправильное сообщение об ошибке, вызванное ошибкой в ndk-gdb. Если я запускаю ndk-gdb - start --verbose, я получаю эту запутанную ошибку:
Android NDK installation path: /home/marco/dev/android-ndk
Using specific adb command: /home/marco/dev/android-sdk//platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.26
Using final ADB command: '/home/marco/dev/android-sdk//platform-tools/adb'
Using auto-detected project path: .
Found package name: com.marco83.siege
ABIs targetted by application: armeabi
Device API Level: 8
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.marco83.siege/lib/gdbserver
Using gdb setup init: /home/marco/dev/siege_game/trunk/SiegeGameNative/libs/armeabi/gdb.setup
Using toolchain prefix: /home/marco/dev/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
Using app out directory: /home/marco/dev/siege_game/trunk/SiegeGameNative/obj/local/armeabi
Found data directory: 'run-as: Package 'com.marco83.siege' has corrupt installation'
Found first launchable activity: .Main
Launching activity: com.marco83.siege/.Main
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb shell am start -n com.marco83.siege/.Main
Starting: Intent { cmp=com.marco83.siege/.Main }
Warning: Activity not started, its current task has been brought to the front
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb shell sleep 2
Found running PID: 844
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb forward tcp:5039 localfilesystem:run-as: Package 'com.marco83.siege' has corrupt installation/debug-socket
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb shell run-as com.marco83.siege lib/gdbserver +debug-socket --attach 844
Android Debug Bridge version 1.0.26
-d - directs command to the only connected USB device
returns an error if more than one USB device is present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
-s - directs command to the USB device or emulator with
the given serial number. Overrides ANDROID_SERIAL
environment variable.
-p - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
connect [:] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
disconnect [[:]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number is specified.
Using this ocmmand with no additional arguments
will disconnect from all connected TCP/IP devices.
device commands:
adb push - copy file/dir to device
adb pull [] - copy file/dir from device
adb sync [ ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
adb shell - run remote shell interactively
adb shell - run remote shell command
adb emu - run emulator console command
adb logcat [ ] - View device log
adb forward - forward socket connections
forward specs are one of:
tcp:
localabstract:
localreserved:
localfilesystem:
dev:
jdwp: (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-s' means install on SD card instead of internal storage)
adb uninstall [-k] - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints:
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip - restarts the adbd daemon listening on TCP on the specified port
networking:
adb ppp [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ ]
can be interpreted in several ways:
- If is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition
is updated.
environmental variables:
ADB_TRACE - Print debug information. A comma separated list of the following values
1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given.
ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed.
ERROR: Could not setup network redirection to gdbserver?
Maybe using --port= to use a different TCP port might help?
marco@pacer:~/dev/siege_game/trunk/SiegeGameNative$ run-as: Package 'com.marco83.siege' has corrupt installation
, которая, как вы можете видеть и как указано здесь: http://vilimpoc.org/blog/2010/09/ 23 / hello-gdbserver-a-debuggable-jni-example-for-android / вызвано сочетанием различных одновременных выходов; реальная ошибка должна быть
Package 'xxxxx' has corrupt installation
Дальнейшее расследование этой ошибки указывало мне на: http://osdir.com/ml/android-ndk/2010-08/msg00263.html
, где сообщается о той же ошибке , и они говорят, что на Desire невозможно отладить изначально. Проблема в том, что run-as
не может получить доступ к папке / data.
Любое решение, кроме рутирования / перепрошивки телефона? Почему запускается как
доступ / данные?
Я думал о наивном решении, в котором я копирую пакет (objs, libs, ...) в более легкодоступное место (например, на SD-карту) и сообщаю отладчику, что вместо этого нужно получить доступ к этому месту - возможно ли это?
Спасибо Marco
РЕДАКТИРОВАТЬ: Обновление: Я рутировал телефон с помощью unrevoked3. Даже если я установил chmod 0777 data
(что, вероятно, ОЧЕНЬ опасно), я получаю ту же ошибку. Как сообщается во второй ссылке в сообщении, run-as проверяет, доступен ли / data. Как мне получить доступ к исходному коду, запускаемому от имени? Можно ли его перекомпилировать и загрузить модифицированную версию, которая работает в обход этой проверки? (поскольку я могу установить / data в любом случае доступными для чтения всем)