Apktool + Eclipse Dynamic Debug apk

Source: Internet
Author: User

Use will Andbug, although very strong but as a habit of od,edb as a dynamic debugging tools, naturally some not accustomed to, so seek new dynamic debugging solutions. But most are NetBeans + Apktool, thinking more about the next IDE on all sorts of irritability, or looking for a combination of eclipse.
Http://code.google.com/p/android-apktool/wiki/SmaliDebugging

Find Apktool's official website, see that there are dynamic debugging can be achieved. You can add android:debuggable= "true" to the manifest file in the target apk by setting parameters at the time of decompile and writeback, and then automatically change the. smali suffix to. java in order to combine eclipse. This can be used for debugging. Of course, don't forget to return to PostScript also need signature, and then wrote a simple script:

"' Created on 2014-5-28@author:xbalien '" Import osimport sysimport subprocessclass Apkdebugger (object): Def unpackagin g (Self, Apk_path): print ' Start unpackaging ... ' Subprocess.call ([' Apktool_2.0.0b9.jar ', ' d ', '-d ', apk_path],sh ELL=TRUE) def packaging (self, file_path): print ' Start packaging ... ' Subprocess.call ([' Apktool_2.0.0b9.ja R ', ' B ', '-d ', file_path],shell=true) def signer (self, unsigned_path): print ' Start Signing ... ' signer_comm= [' Jarsigner ', '-verbose ', '-keystore ', ' key ', '-digestalg ', ' SHA1 ', '-sigalg ', ' md5withrsa ', '-signedjar ', ' signed.apk ' ] Signer_comm + = [Unsigned_path, ' key '] p = subprocess. Popen (signer_comm,stdin=subprocess. Pipe,stdout = subprocess. PIPE, stderr = subprocess. PIPE, Shell = True) p.communicate (input= ' key123456 ') p.wait () def zipalign (self, outapk_path): Sub Process.call ([' zipalign ', '-V ', ' 4 ', ' signed.apk ', outapk_path],shell=true) if __name__ = = ' __main__ ': If Len (SYS.ARGV) & Gt;1:        print ' Start Create apkdebugger ... ' apk_path = sys.argv[1] File_path = apk_path[:-4] Unsigned        _path = './' +file_path+ '/dist/' +apk_path outapk_path = file_path+ '//' +apk_path Apk_debugger = Apkdebugger () Apk_debugger.unpackaging (Apk_path) apk_debugger.packaging (file_path) Apk_debugger.signer (unsigned_ Path) apk_debugger.zipalign (outapk_path) else:print ' useage:main.py apk_name '

After the script is processed, the APK is generated. Then install it on your phone. Click Run. This can be viewed through DDMS



Open Eclipse, create a new Java project, add source code (decompile code Smali directory)



After that, we can open a breakpoint on the file.


Then set the Debug configuration file, select Remote Debugging and the corresponding port to start debugging


then click Debug. This is the time to start clicking on your phone. It breaks down at the corresponding breakpoint.


Then you can have a pleasant step

Related Article

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.