Two ways to debug Android app

Source: Internet
Author: User

Method One:

1. decompile the APK file using the-D option of Apktool

Java-jar Apktool.jar d-d target.apk-o output

2. Add android:debuggable= "True" to the application node of Androidmanifest

3. Add the following code to the OnCreate of the class at the entry point to wait for debugging

invoke-static{}, Landroid/os/debug;->waitfordebugger () V

4. Back to compile apk

Java-jar Apktool.jar b-d Output-o newtarget.apk

5. Sign the APK

Java-jar Signapk.jar Testkey.x509.pem testkey.pk8 newtarget.apk signed.apk

6. Install the signed apk into the phone or simulator

ADB install signed.apk

7. Import the Smali code from 1 into Android studio

File→open→output directory → next Breakpoint

8. Open Monitor to find the appropriate process

Run →monitor or Tools->android->android Device Monitor

9. Configure Remote debugging options

Run→editor Configurations→defaults→remote, click on the + sign add a, host for Localhost,port for 8700

10. Open the APK and click on the green bug to start debugging

Method Two: No need to modify the original apk file

1. decompile the APK file with tools such as Android killer

2. Insert the Smali code into Android studio and install the Smaliidea plugin

File→settings→plugins→install plugin from disk ... →restart

3. Configure remote debugging options to open monitor

4. Use ADB to start the APK in debug mode

ADB shell am start-d-N package/activitiyname

5. Start debugging under Breakpoint, add register in Watch

Two ways to debug Android app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.