Today, to install two identical applications on Android phones, I thought we could install different versions, tried them several times, and covered each other, so we could only try to modify the package name (package name) of the APK.
Purpose Statement : This article is only to meet the needs of DIY, not to become a packaging party, stealing other people's work, the tools involved in this article are open source, only for learning and exchange.
DIY premise : In the domestic forum, search for a moment, found a variety of unpack, packaging technical content, as well as a variety of Chinese, to advertising posts, but this is not the purpose of this article. I've seen it before. The Party not only modifies other people's APK ads for profit, also will others APK package name modified, so someone has already realized, but could not find the relevant technical articles, this article involved in the knowledge is still relatively simple, there is no in-depth study of the underlying causes, but also referred to a few online posts.
PS: In the domestic forum, find an original post is very difficult, the basic is reproduced, also does not attach the original link, introduced a lot of mistakes, to find the original text is very difficult, it is very tragic. Domestic forum, enthusiastic people or less, a lot of problems are dead, no answer, I tried in csdn, Iteye, EoE sent a few posts, but rarely solve the problem, so can only turn to foreign forums, which is also a tragedy.
This problem solved, also very simple, at least I this relatively simple, I want to install more than a few QQ browser (there is it cock wire installed 10 Micro-letter, this I said very Khan), the basic process is as follows:
1, the APK solution into a folder
2, modify the corresponding package name in Androidmanifest.xml
3, modify the package in the Smali directory
4. Pack the folders into apk
5. Re-sign the APK
6, verify the APK signature
7. Optimize APK
8, install APK, and test
Basic Prerequisites :
1, the Java environment
2, Eclipse and Android development environment (this is mainly used for debugging)
3, text editor, I used the uedit, can also use a similar, mainly using its search and replace functions
This article is mainly used to decompile apk get the source code, but Google has been reversed, can only get some of the readability of the source code, here is mainly the use of decompile APK generated program source code and pictures, XML configuration, language resources and other documents.
The apktool-1.0.0.tar.bz2 and Apktool-install-windows-2.1_r01-1.zip mentioned in the references are available from Http//code.google.com/p/android-apktool /download, after downloading, will be involved in the command line directory and EXE directory to add to the path of the computer, so easy to operate, such as detection apktool can be, can be entered in the command line Apktool, if you can identify the OK.
After referring to the technical articles in China, someone posted to the above ideas to operate, but did not send technical articles, so I can only go to the foreign forum to stroll, in the stack overflow, found the relevant posts, there are foreigners message "you can ' t does this", which is indeed contrary to technical ethics, But here only do study reference or Exchange. Found a piece of post http://stackoverflow.com/questions/9218641/renaming-the-package-name-inside-an-apk, the answer to this post gave a more detailed steps (such as the above) , his situation is slightly more complex than this, the simplification is the result I want, I just follow this basic step, the answer to the English comparison understood (most likely the Chinese).
Follow the steps above step by step: I have QQ browser 4.0 version of the APK to operate.
1, my apktool installed in the E-disk under the Apktool directory , so the operation is also in this directory E:\apkTool
Copy the APK to the E:\apkTool directory and rename it to qq4.0.apk (this is not required, just as it pleases).
APK unpack the command line CD to E:\apkTool this directory Apktool D qq4.o.apk qq4 will apk unpack to qq4 (this can also be arbitrary) this directory
E:\apkTool\qq4 the contents of this directory are as follows:
2, modify the package name in the Androidmanifest.xml ,
Change the package name COM.TENCENT.QBX after package to the name of the new package you want, and I changed it to Com.tianxiao.tencentweb
Change the package name in the declaration of the related activity of COM.TENCENT.QBX, which involves the original package name, to the new package name Com.tianxiao.tencentweb
As for the intent-filter inside the action name contains the original package name, you can not change, if the change, the code should also be the corresponding changes
In addition, if there is a provider,provider of the authorities also have to change, this on the same phone must be unique, or installation will fail
3, in the E:\apkTool\qq4\smali directory , there are many subdirectories, subdirectories under the Smali end of the file, the syntax of the file is similar to the assembly language, the specific principle is not to delve into.
Change the form of the original package name in all files in the Smali directory COM/TENCENT/QBX to the new package name Com/tianxiao/tencentweb
as follows, use Uedit to replace in the file, the target directory point to E:\apkTool\qq4\smali, this nearly 1000
Change the package name COM.TENCENT.QBX in the string form to Com.tianxiao.tencentweb if it is changed to the package name in the action.
If there are provider also want to say the original authorities value changed to androidmanifest.xml in the new authorities value.
4. Repackage the E:\apkTool\qq4 as apk
Apktool b qq4 newqq.apk
5. Re-sign the new newqq.apk
There are many ways to sign, one is to manually generate the signature and use the command line signature
I used ready-made, downloaded a auto-sign folder, signed, this relatively simple, online posts a lot, do not repeat.
APK named newqq4signed.apk after the new signature
6. Verify that the signature is correct
Jarsigner-verify-verbose-certs newqq4signed.apk
Generally, no problem, skip.
7. Optimize APK
Zipalign-v 4 newqq4signed.apk latestqq.apk optimized apk named latestqq.apk
8, install the new APK, verify the success
It's best to open eclipse, phone, and view Logcat installation information.
I tried 3 times to succeed, mainly to forget the provider of the authorities treatment,
The error message is as follows: Can ' t install because provider name Qbx_bookmarks (in package com.tianxiao.tencentweb) are already used by Com.tenc Ent.qbx
The reason is clear, so debug is still very strong, originally did not like debug, see the debug process can better understand the implementation process.
After the test, the author has repeated 2-8 of these steps, a total of 4 new apk, after the installation of the results shown below:
As pictured, QQ4.0 's browser, the original installed A, repackaged 4, the expected target reached.
This attempt to succeed, spent a lot of time to check the data, the basic principle is quite clear, this article in the author as far as possible without ambiguity, welcome you to exchange and criticism.