To salute the classic "Hello, World," we also start with a simple program Helloworld.apk. When you install the APK on your phone, a line of text "Hello, world!"is displayed on the screen. Now we want to inject the "Hello world~!" into the way Change to "Hello World" in Chinese.
1. Anti-compilation
Dos command Prompt line input apktool.bat d helloworld.apk
When this command finishes running, a directory named Helloactivity is generated under the current directory .
The structure of the directory is ( name followed / indicates this is a directory ):
helloworld/
|--------------androidmanifest.xml
|--------------apktool.yml
|--------------res/
|--------------smali/
2. Code injection
Open The Smaili directory to find the code that needs to be injected,Mainactivity.smali. Open the file with a text editor. Search the keyword "Hello world" to find the code
Change to "Hello World". (Here we can also insert our code, interested friends can learn the next Smali syntax:http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html)
3. RePack The build 1.APK
Save the file. Command line Apktool.bat b HelloWorld 1.apk build apk file.
4. Sign the newly generated apk file
Since we repackaged the apk file, the signature has been lost, so we have to re-sign the app before it can be installed. Here we use the jdk/bin/jarsigner.exe.
Command line input jarsigner-keystore e:\\keystore\1.keystore-storepass 123123-verbose 1.apk zs.keystore
Description Jarsigner-keystore [ signature file path ] -storepass [ password ] -verbose [ requires signature file path ] [ signature file alias ]
5. Delete the original HelloWorldon the phoneand reinstall our modified apk file.