I am using a guide to Decompile and Debug an APK but I can not pass the last step. Where when trying to Debug APK on my phone from Android Studio, an error appears: "Wait for Debugger". According to the guide I must execute the code:
adb forward tcp:5005 jdwp:$(timeout 0.5 adb jdwp | tail -n 1)
But since I do not have Linux (I have windows), I do not know what code I should execute. Thank you very much for your help!
Guide: https://malacupa.com/2018/11/11/debug-decompiled-smali-code-in-android-studio-3.2.html
First make sure you have adb in your path.
Then open a cmd.exe and run this command:
adb jdwp
and take note where application’s debug interface is listening. I'll call this value jdwp-port from now on.
Now execute the following command:
adb forward tcp:5005 jdwp:jdwp-port
and you should be fine. REMEMBER to change jdwp-port with the value you got from the first command.
Good luck.
But since I do not have Linus (I have windows)
It is actually called Linux anyway.
As a side note, you should check the official AOSP documentation on how to use GDB here: https://source.android.com/devices/tech/debug/gdb
Related
I have some test data for my program that i want to push to the device before a test activity is run or debug. On the command line this is:
adb -s RF8M40T69JX push --sync -z any test_data /storage/emulated/0/Download/test_data
I know i can run an external tool shell script with the "Before launch" configuration option. But this does not give me any way to know on which device Studio want to start it. I don't want to waste the time and dispatch to every possible device and every Edit-Compile-Run cycle.
I checked that the device signature is unfortunately not passed as environment variable to external tools as it should be. Is there any other way? Can i do this with some Gradle magic?
I use Qt Creator to develop an Android dynamic library, i.e. a .so file. This .so file is then used by an Android application, but that is developed in Eclipse.
I need to debug my native code, but since it's a library, I can't start the application from Qt Creator, I must attach to the already running process.
Now, if it were a desktop application, I'd use Debug->Start Debugging->Attach to Running Application, but how do I attach to an Android process, which would be running on the emulator or on a connected phone, which is more like remote-debugging?
I think that I should use Debug->Start Debugging->Attach to Running Debug Server:
However, I'm not sure what the exact steps are - how do I start a debug server for ADB, and which port do I connect to?
So it looks like there may be another way to set up a debugger that can connect properly.
http://lists.qt-project.org/pipermail/qt-creator/2012-June/001017.html
Set a toolchain with this version of gdb, and set your project to use it.
In Tools -> Options -> Debugger -> GDB insert your commands in "Additional
Startup Commands"
...
I use Debug -> Start Debugging -> Attach to Remote. All the fields are
there (solib-absolute-prefix is an alias for sysroot, and "location of
debugging information" is solib-search-path), and the last few
"configurations" are stored, so you can call them back easily. I have
to start gdbserver on the target manually, set a shortcut to open the
'attach to remote' dialog, and it is been working great for me so for.
It's old (June 2012), but it goes into better detail about how the gdbserver is started and the setup for a debugger and attaching to a process in Qt. It also mentions some of the relevant environment variables:
set solib-absolute-prefix $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/
set solib-search-path $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/system/lib/
Hope that helps.
Attaching to a adb logcat is independent of Qt and what Android source you are using. Make sure adb.exe can be found on your path such as: C:\Android\SDK\platform-tools, and you have the adb drivers for the device you are debugging with. Try this one if you are struggling: http://www.koushikdutta.com/post/universal-adb-driver
Command Line ADB commands
This should print out any connected devices that can be found:
adb devices
This clears the current logcat logs:
adb logcat -c
This starts a connection to logcat:
adb logcat
Usually you don't have to worry about which port to connect to, because it is automatically found by adb.
Attaching to logcat over wifi is also do-able.
adb tcpip
adb connect 192.168.XX.XX:5555
Hope that helps.
I want to use ECLIM plugin for VIM during android development.
The main problem : I can't run my project from eclim, so I can't see logs and errors.
I know such command :
:Ant debug install
This command compiles and updates my project to connected device. I have to run it manually.
I'm not lazy, and is not problem to run it.
But I wish to see runtime's Logs.:)
open a terminal,and input adb logcat,then you can see the log.
have a try :)
If you want to see it exclusively within vim then :!adb logcat will display the logs.
Use this in vim:
:!ant debug install && adb shell am start -n your.package.name/.YourActivityName
That will fire up the app in your device. For logging I just want to complement that if you log in your app use a tag and filter the log by a tag like so: adb logcat -s "tagname"
I keep reading tutorials where I'm supposed to enter something into the ADB command line and that it's in my Android sdk/platform-tools. So I find it, click on it, and a black screen comes up for about 2 seconds and while it's up, it scrolls through a bunch of text. So how am I supposed to use this "adb"?
It is called the Android Debug Bridge, and the Android Developers Site documentation does a better job of explaining it than I can:
http://developer.android.com/guide/developing/tools/adb.html
If you are looking for the adb command line, navigate to <sdk>/platform-tools/ and run
adb.exe shell
from the command line.
Pretty sure that is well documented since day 1 on the Android Debug Bridge
Android Debug Bridge (adb) is a versatile command line tool that lets
you communicate with an emulator instance or connected Android-powered
device. It is a client-server program that includes three components:
A client, which runs on your development machine. You can invoke a
client from a shell by issuing an adb command. Other Android tools
such as the ADT plugin and DDMS also create adb clients. A server,
which runs as a background process on your development machine. The
server manages communication between the client and the adb daemon
running on an emulator or device. A daemon, which runs as a background
process on each emulator or device instance.
So plain old English, ADB can be found on %ANDROID_HOME%/platform-toos/, and it's this magical command line that allows you to comunicate with your mobile device, either a physical or a Virtual device (AVD), so whenever you deploy you are passing the application through the device thanks to the ADB on a specific client port on your computer to the daemon port on the device.
Interesting things you can do with it?
Logcat: ./adb logcat allows you to see the log trace of each proces.
Install: ./adb install allows you to install apk to the device.
Killing:./adb kill-sever
Starting:./adb stat-server
Enter SQLite3: adb -s your_device shell
Use the monkey: adb shell monkey -v -p your.app.package 500 to
generate random events
And a lot more! Read the documentation it's beatiful and self-explanatory.
When I want to test an android application, I create a new AVD, start it in the emulator, wait for the emulator to finish booting, and then use ADB to install the application, and when I'm done delete the AVD. Are there any tools that automate all of those steps? I tried writing my own but I couldn't find a way to tell if the emulator was completely booted, as the Android SDK website says not to use "adb wait-for-device install file.apk".
You're right not to use wait-for-device. It does not wait for the package manager to be available, which is what you need. I'm not sure how eclipse does it but you can poll the emulator until the package manager is available using the command adb shell pm path android. The command should return 'package: something'. Check out this python script that uses the technique: www.netmite.com/android/mydroid/1.6/.../adb_interface.py. It's pretty big but if you search for the command above you'll find the relevant piece of the script.
Why do you want to delete the AVD every time?
If you are deleting it every time because the install command throws an error due to the app already existing on the AVD, you can do this: adb install -r file.apk. The -r part is used for reinstalling the app. Here is the full usage instructions for adb.
Are you deleting it to remove the application you are testing and revert to a 'clean' emulator? If so it's not necessary to delete the AVD every time. You can specify the -wipe-data option when starting the emulator. This effectively resets the AVD to how it was when you created it. Here is the emulator documentation.
Hopefully that helps simplify your script.