# Android Debugging

Debugging is a method used to inject/modify application function during runtime process

Android application must be flagged as debuggable in order to be able to test the debugging.

## Debugging android apps

In order to do that, first we need to check if the application is debuggable or not by exploring the AndrdoiMainfest.xml file and look for the debug flag

* Debug InsecureBankv2.apk
* Look for the mainfest file for `android:debugging=true` flag
* run the following command using adb

```
./adb jdwp
```

* Note the IDs and then lunch the application
* run adb again and take a note of the new ID (this the id for the InsecureBankv2 application)

```
./adb jdwp
```

* Enter the following command to create a new connection listening on 12345 to which we later connect using jdb.

```
./adb forward tcp:12345 jdwp:<id from last step>
```

* Connect to 12345 using jdb.&#x20;

```
jdb -attach localhost:12345
```

* The list of all the available classes can be viewed using the command “classes”.
* Methods for a specific class can be found using the below command:&#x20;

```
methods com.android.insecurebankv2.LoginActivity
```

* Set Breakpoint

```
stop in com.android.insecurebankv2.LoginActivity.createUser()
```

* Click on create user button to hit the breakpoint
* The command “local” can be used to view the current local variables and the “step” command can be used to move to the next instruction.
* Check the local variables

```
main[1] step
main[1] locals
```

* Modify variable

```
main[1] set text = "Hello World"
main[1] run
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://co0nan.gitbook.io/mobile-application/android-debugging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
