Alex Rivera | Logout

Renaming the Package Name inside an APK

Asked 2012-02-09T20:57:07.213
8

I have created an AIR app that is currently on the market. To update the app, obviously I must keep the same package name. My first version's were packaged using Eclipse with the ADT plugin.

Now to use AIR 3.0 Native Extensions (ANE) which were not available when I first developed the app, I currently must create my APK using AIR's command line tools. Unfortunately, these command line tools force you to have a package name that starts with the word "air". For example, I need the package name "com.example". AIR creates the package name as "air.com.example".

So now, I cannot update my app in the market since the package name has changed. Adobe has this horrific article to help you rename and remove the "air" in the package. I'm not a great programmer so this has really stumped me. http://kb2.adobe.com/cps/875/cpsid_87562.html

Apparently this info is out of date or incorrect in a few areas. I have completely stumbled at step 12 which uses apkbuilder:

 apkbuilder final.apk -u -z resources.arsc -f classes.dex

I am getting this error message:

THIS TOOL IS DEPRECATED. See --help for more information. java.io.FileNotFoundException: resources.arsc does not exist

I have used step 10 to create the new resources.arsc file. It clearly DOES exist and in the correct location. I tried using apkbuilder with other resources.arsc files taken from other projects. I still get the same error message.

Is there a chance in hell of this working? If anyone is interested in this, I have a zip file with a sample AIR apk, windows bat files for all the command line work, and all the needed utilities so they don't need to be downloaded. To get started you just need to change my path.bat to fit your system. And you need notepad++

Edit
Report

1 Answer

1

I actually tried brad's approach and couldn't imagine having to go through the process EVERY TIME i compiled a release. so i did something else...i modified ADT so it doesn't insert "air." at the start and replaces it with a more useful extension like "com."

Here's a summary of the approach:

use: jar xf adt.jar

to extract the adt.jar file to a directory on your desktop. you'll find it in {adobe SDK}/lib/

look for the file APKOutputStream.class

com/adobe/air/apk/APKOutputStream.class

Open it in a hex editor (eg, HxD is what i used). Search for "air." (without the quotes but including the dot).

Don't delete the entry. i tried, you can't, it corrupts the class and it won't run. What you can do, however, is replace "air." with "com." because it has the same number of characters and doesn't mess with the length of the file. The com prefix is a lot more useful to most of us.

save the modified APKOutputStream.class file and repackage with JAR. something like this:

jar cfm ..\patchedadt.jar ..\MANIFEST.MF *

you'll want to copy that MANIFEST.MF file from the subdirectory of the package called META-INF

Rename your patchedadt.jar to adt.jar and put it back in the lib directory. Works with the Flash Builder and all that garb.

Needless to say, when you're in there, you'll want to produce your package without a "com." prefix so you don't end up with com.com.your.package.name.

maybe there was an easier way, but i didn't know any better and no one else had an answer except to decompile the apk, modify it, and recompile and that didn't even work. so i figured i'll share what i did in case someone else stumbles on it later :)

jim

answered 2013-02-09T21:10:53.937

Your Answer