简体   繁体   English

Android:在Eclipse中重命名包

[英]Android: Rename Package in Eclipse

Is there a way to excecute the Eclipse command "Android Tools -> Rename Application Package" as a script from the shell? 有没有办法将Eclipse命令“Android Tools - > Rename Application Package”作为脚本从shell中排除?

I want to compile my Android application several times with different options (eg free and paid version) without doing some things manually. 我想用不同的选项(例如免费版和付费版)多次编译我的Android应用程序,而无需手动执行某些操作。 It is important to do this automatically. 自动执行此操作非常重要。 All solutions like libraries won't help because several things have to be done by hand. 像图书馆这样的所有解决方案都无济于事,因为有几件事需要手工完成。

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 . 您必须手动调用aapt工具来打包已编译的项目,然后再次调用aapt来添加类,使用jarsigner签名并将其与zipalign对齐。 Normally, the Eclipse ADT plugin does the chain of build steps for you. 通常,Eclipse ADT插件会为您执行构建步骤链。

Example calls of the steps would be following. 下面将对步骤进行示例调用。

  1. 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 
  2. Then add the classes: 然后添加类:

     aapt add -f renamed_project.apk.unaligned classes.dex -v 
  3. Sign it: 签字:

     jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 \\ -keystore "some_keystore_file" \\ renamed_project.apk.unaligned "key_name" 
  4. 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 . 您也可以使用Ant更轻松地完成此操作。 Here you can find some more information. 在这里您可以找到更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM