Smalidea non-source debugging Android app

Source: Internet
Author: User

Smalidea is a Smali plugin for IntelliJ idea/android Studio

Features already available
    • Syntax highlighting/error hints
    • Byte code level debugging
      • Breakpoint
      • Single-Step debugging
      • Register view
      • Native Windows Java syntax support, same support in debug mode
    • Support Jump, easy to track variables/functions/classes. (XRef also supported)
    • Find usage
    • Renaming
    • Referencing the Smali class from Java code
    • Error feedback ...
Installation
    • Download Plugin Smalidea
    • Enter IntelliJ idea/android Studio to start installing the plugin, enter Settings->plugins Click to Install plugin from disk Select the downloaded package.
    • Clickapply
Turn on application debugging

To debug the Dex code inside an APK, you must meet either of the following two conditions:

    • The application tag in the Androidmanifest.xml file in the APK contains the property android:debuggable= "true"
    • The value of ro.debuggable in/default.prop is 1

Optional options:

    • Apktool Insert Android:debuggable= "true" in Androidmanifest.xml file after anti-compilation app
    • Hook system Debug (Xinstaller)
    • Modify Boot.img

Personally think to change boot.img and two times packaging is more troublesome, so here use hook way to open all application debugging purposes, xposed plug-in code as follows

123456789101112131415161718192021222324252627282930313233343536373839 publicclass Debug implements IXposedHookLoadPackage {    publicboolean debugApps = true ;    publicstatic final int DEBUG_ENABLE_DEBUGGER = 0x1;    publicString tag = "IDG";    @Override    publicvoid handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throwsThrowable {        if(lpparam.appInfo ==null ||                (lpparam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) !=0){            return;        }        tag = tag + lpparam.packageName;        XposedBridge.hookAllMethods(Process.class,"start",new XC_MethodHook() {            @Override            protectedvoid beforeHookedMethod(MethodHookParam param) throwsThrowable {                 intid = 5;                intflags = (Integer) param.args[id];                Log.d(tag,"flags is : "+flags);                if(debugApps) {                    if((flags & DEBUG_ENABLE_DEBUGGER) == 0) {                        flags |= DEBUG_ENABLE_DEBUGGER;                    }                }                param.args[id] = flags;                Log.d(tag,"flags changed : "+flags);            }        });    }}

Effects such as

If you encounter the following error

Adb rejected connection to client

You can use the restart ADB server to resolve

ADB kill-serveradb Start-server
Debug your App

Note: The idea 14.1 and later only supports single-step debugging

  • apply

    Baksmali
    baksmali myapp.apk-o ~/projects/myapp/src 
  • Go to Idea, import a new project, select the previous directory

    ~/projects/myapp

  • Select when importingCreate project from existing sources

  • After successfully importing the project, right click on the SRC directory, setMark Directory As->Sources Root

  • Open Module setting The JDK that corresponds to the setting

  • install debug application

    adb Install com.zkj.guimi.apk 
  • Find the debug application process, launch the application

    ? ADB shell am start-d-w-n com.zkj.guimi/.ui. SplashScreen?                                                                                                         ADB Shell PS |grep Guimi 1. u0_a157 9879 242 883420 36360 ffffffff 00000000 S com.zkj.guimi? ADB forward tcp:8700 jdwp:9879 
  • Configure remote debugging on idea (Run->edit configurations), change the debug port to 8700

  • Run->debug

    Connected to the target VM, address: ' localhost:8700 ', Transport: ' Socket '

  • Single-step debugging after a breakpoint is triggered

Reference

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Smalidea non-source debugging 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.