Reputation: 51
Is there a way to excecute the Eclipse command "Android Tools -> Rename Application Package" as a script from the shell?
I want to compile my Android application several times with different options (e.g. free and paid version) without doing some things manually. It is important to do this automatically. All solutions like libraries won't help because several things have to be done by hand.
Upvotes: 4
Views: 1345
Reputation: 23977
Yes, it is possible. You have to manually call aapt
tool to package the compiled project, then call aapt
again to add the classes, sign it with jarsigner
and align it with zipalign
. Normally, the Eclipse ADT plugin does the chain of build steps for you.
Example calls of the steps would be following.
Packaging the app with different package name:
aapt package -f -M ./AndroidManifest.xml -S res/ \
-I android.jar -F renamed_project.apk.unaligned \
--rename-manifest-package "com.example.some_new_package" -v
Then add the classes:
aapt add -f renamed_project.apk.unaligned classes.dex -v
Sign it:
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 \
-keystore "some_keystore_file" \
renamed_project.apk.unaligned "key_name"
Align it:
zipalign -v 4 renamed_project.apk.unaligned renamed_project.apk
Some more information can be found for example here.
Also you can do it more easily with Ant
. Here you can find some more information.
Upvotes: 1