Can apktool change package name?

3,449 views
Skip to first unread message

andyg...@hotmail.com

unread,
Jan 2, 2013, 1:33:59 PM1/2/13
to apk...@googlegroups.com
Hello apk experts, I was wondering if you can give me some advice. I am developing a series of open source live wallpapers that are meant to be customized and adopted by organizations (like schools) for the purpose of fundraising. The wallpapers are meant to have their graphics and text replaced to create custom wallpapers for the organization (e.g. with school logo and colors). There are examples and more details at waddafundraiser.org. This is a perfect example where reverse-engineering and recompiling an apk is legal and encouraged! I am looking for a way that organizations can take and make these wallpapers their own without needing to install the Android SDK. Replacing the graphics is straightforward with zip and jarsigner. Modifying the XML (the name, etc) looks possible with apktool or aapt. But what I haven't been able to figure out is changing the package name so that a wallpaper is installed as if it was built by each organization. This is needed so that different customizations of the same wallpaper can be installed as separate instances. (It won't work if they all leave the default package name waddacube.waddafundraiser.org.)

Can apktool be used to change the package name? Are there any other tools that can do this?

Any recommendations are greatly appreciated.

Thanks,
Andrew

Ryszard Wiśniewski

unread,
Jan 3, 2013, 3:48:05 AM1/3/13
to apk...@googlegroups.com
Hi,

you don't have to use apktool - at least on the organizations side. Distribute it as:

- resources of your app
- classes.dex
- public.xml - you can get it by building your app and "apktool d" it - file will be in res/values
- framework resources - you can use "apktool if" so file will be smaller
- aapt, zip, zipalign, jarsigner tools
- simple script to automate building

Then in your script call aapt with --rename-manifest-package parameter. It'll rewrite all references to the original package name in AndroidManifest.xml, so it should be ok. Of course it won't always work, e.g. if you have declared your own XML attributes or placed package name as a string in the application code, but I think this isn't a problem for you.

Application should work without a public.xml file, but it may save you from some annoying force closes.

Regards
Ryszard Wiśniewski

andyg...@hotmail.com

unread,
Jan 5, 2013, 4:28:28 PM1/5/13
to apk...@googlegroups.com
Thank you very much. This looks like it will work well. I was able to use aapt to create an apk with a different package name and it runs. However, I used an android.jar file from the SDK as an input to aapt. I was unable to determine how to use the framework resources you suggested. Could you please provide more details on where to get these framework resources and how to get aapt to use them? If I pull the resources.arsc from the android.jar file is there a way for aapt to use that? If so I could not find it.

Thanks again,
Andrew

Ryszard Wiśniewski

unread,
Jan 5, 2013, 6:58:08 PM1/5/13
to apk...@googlegroups.com
I mean you can run "apktool if" on this android.jar file from the SDK and resulting file (1.apk, rename it if you want) will be much smaller, but still usable by aapt -I. For me it's 18MiB vs. 5.4MiB. Smaller size may be better for you because you have to distribute this file with your app.

andyg...@hotmail.com

unread,
Jan 5, 2013, 8:42:27 PM1/5/13
to apk...@googlegroups.com
Thank you! You have contributed a key piece to waddafundraiser.org. We will be free from the Android SDK!

Thanks again,
Andrew

P.S. If anyone comes along and is interested I was able to zip the resources.arsc from android.jar into a file named res-system.apk and then aapt was able to recognize it with -I (having resource.arsc zipped was important to aapt). This is the same thing "apktool if" does for you as well if you have that installed.
Reply all
Reply to author
Forward
0 new messages