重命名 APK 中的包名称 [英] Renaming the Package Name inside an APK

查看:31
本文介绍了重命名 APK 中的包名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 AIR 应用,目前已在市场上销售.要更新应用程序,显然我必须保持相同的包名.我的第一个版本是使用带有 ADT 插件的 Eclipse 打包的.

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.

现在要使用在我第一次开发应用程序时不可用的 AIR 3.0 Native Extensions (ANE),我目前必须使用 AIR 的命令行工具创建我的 APK.不幸的是,这些命令行工具强制您使用以air"一词开头的包名.例如,我需要包名com.example".AIR 将包名称创建为air.com.example".

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".

所以现在,由于包名称已更改,我无法在市场上更新我的应用程序.Adobe 有这篇可怕的文章来帮助您重命名和删除包中的空气".我不是一个伟大的程序员,所以这真的让我很难过.http://kb2.adobe.com/cps/875/cpsid_87562.html

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

显然,此信息在某些方面已过时或不正确.我在使用 apkbuilder 的第 12 步完全绊倒了:

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

我收到此错误消息:

此工具已弃用.有关更多信息,请参阅 --help.java.io.FileNotFoundException: resources.arsc 不存在

我已经使用步骤 10 创建了新的 resources.arsc 文件.它显然确实存在并且位于正确的位置.我尝试将 apkbuilder 与从其他项目中获取的其他 resources.arsc 文件一起使用.我仍然收到相同的错误消息.

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.

这种工作有机会吗?如果有人对此感兴趣,我有一个包含示例 AIR apk 的 zip 文件、用于所有命令行工作的 windows bat 文件以及所有需要的实用程序,因此不需要下载它们.要开始,您只需要更改我的 path.bat 以适合您的系统.并且您需要记事本++(或等效物)来批量自动重命名多个文件中的包名称.bradwallacedesign.com/dktimer/renameApkProject.zip

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++ (or an equivalent) to batch automate renaming the package name across several files. bradwallacedesign.com/dktimer/renameApkProject.zip

非常感谢!

推荐答案

这是在 PC 上完成的.我不知道如何在 Mac 上执行此操作.

this was done on a pc. i have no idea how to do this on a mac.

我不建议使用它来去除空气".来自空气包名称.如果您这样做,则不会提示用户在其设备上下载 air.用户将收到一条错误消息,而对问题一无所知.当然你可以使用 air captive runtime 来解决这个问题.

i don't recommend using this to remove the "air." from an air package name. If you do so, the user will not be prompted to download air on their device. the user will get an error message instead with no clue to the problem. of course you can use air captive runtime to solve this issue.

http://bradwallacedesign.com/share/renameAPK.zip

下载并解压我的文件 (renameAPK.zip) 到 c:\renameAPK.

download and unzip my file (renameAPK.zip) to c:\renameAPK.

  1. 我的包含 apkTool 的文件 (renameAPK.zip)
  2. java jdk/jre
  3. 安卓 SDK
  4. notepad++(或可以跨多个文件重命名的等效文本编辑器)

我制作了许多 bat 文件,因为我不确定如何将它们合并为一个文件.您需要编辑每一个来更改路径名和文件名,以便与您的计算机和 apk 文件一起使用.

i made many bat files since i'm not sure how to combine them into one file. you will need to edit each one to change your path names and file names to work with your computer and your apk file.

我按照我使用它们的顺序给所有的蝙蝠编号.打开命令行后,我输入我想要的 bat 文件的编号,然后按 Tab 键自动完成 bat 文件的名称,然后按 Enter 运行该 bat 文件.

i numbered all the bats in the order that i use them. once a command line is open, i type the number of the bat file i want then hit the tab key to automatically finish the name of the bat file then hit enter to run that bat file.

双击`openCmd.bat 打开一个命令行,指向包含所有文件的目录.

double click `openCmd.bat to open a command line pointing to the directory with all your files.

0. 运行 0path.bat 来设置您的路径.(我现在不记得是否需要 adobe air sdk,但我有它在我的路径中.显然,需要 JDK,我认为 jarsigner 和 zip align 需要 android sdk.)

0. run 0path.bat to set your path. (i can't remember now if the adobe air sdk is needed for this but i have it in my path. obviously, the JDK is needed and the android sdk for the jarsigner and zip align i think.)

1. 运行 1decompileAPK.bat 让 apkTool 将您的应用反编译到一个名为 UNZIPPEDapk 的文件夹中

1. run 1decompileAPK.bat to have apkTool decompile your app into a folder called UNZIPPEDapk

2. 按照 2editManifest & 中的说明进行操作PackageName - 在 UNZIPPEDapk 中使用 Notepad++ 编辑清单和包名称的说明(不是 bat).txt:

编辑 AndroidManifest.xml:

edit AndroidManifest.xml:

a. 将包名从 air.oldPackageName 更改为 newPackageName

a. change package name from air.oldPackageName to newPackageName

b. 编辑其他需要的条目:

c. 重命名smali"文件夹内的文件夹系统,使其与您的新包名称一起使用例如:如果旧包名称为:air/oldName,则更改文件夹以匹配新包名称:air/newName

b. edit other needed entries:

c. rename folder system inside "smali" folder so that it works with your new package name for example: if the old package name was: air/oldName then change the folders to match the new package name: air/newName

使用 notepad++(或任何可以在多个文件中查找和替换文本的编辑器)

use notepad++ (or any editor that can find and replace text over many files)

d. ctrl+shift+f ---在文件中查找"

d. ctrl+shift+f --- "Find in files"

  find:
air/oldPackageName
  replace with:
newPackageName
  where:
all files in UNZIPPEDapk/smali

(我认为有 200 多个替代品)

(i think there were over 200 replacements)

3. 运行 3buildDistFolder.bat 让 apkTool 在 UNZIPPEDapk\Dist 文件夹中构建新的 apk

3. run 3buildDistFolder.bat to have apkTool build the new apk in the UNZIPPEDapk\Dist folder

4. 按照 4getMissingFiles - instructions.txt 中的说明在新版本中恢复 2 个丢失的文件:

4. follow the instructions in 4getMissingFiles - instructions.txt to reinstate the 2 missing files in the new build:

a. 3buildDistFolder 期间未构建两个文件:

a. Two files were not built during 3buildDistFolder:

3buildDistFolder.bat 在 \UNZIPPEDapk\dist 文件夹中构建了新的 apk,但未能复制 2 个文件:

3buildDistFolder.bat built the new apk in the \UNZIPPEDapk\dist folder but it failed to copy 2 files:

(skipping hidden file 'C:\Users\computer\apkTool\UNZIPPEDapk\assets\META-INF

\AIR\extensions\com.adobe.mobile\META-INF\ANE\Android-ARM.classpath')(跳过隐藏文件 'C:\Users\computer\apkTool\UNZIPPEDapk\assets\META-INF\AIR\extensions\com.adobe.mobile\META-INF\ANE\Android-ARM.project')

\AIR\extensions\com.adobe.mobile\META-INF\ANE\Android-ARM.classpath') (skipping hidden file 'C:\Users\computer\apkTool\UNZIPPEDapk\assets\META-INF \AIR\extensions\com.adobe.mobile\META-INF\ANE\Android-ARM.project')

从您的原始 apk 中抓取这 2 个文件并将它们放入正确文件夹中的新 apk 中

grab these 2 files from your original apk and drop them into your new apk in the correct folder

b. 将 yourApp.apk 从 DKTimer/Dist/复制到 bat 文件所在的根目录.

b. copy yourApp.apk from DKTimer/Dist/ to root directory where your bat files are.

5. 运行 5signAPK.bat 对 apk 进行签名.

5. run 5signAPK.bat to sign the apk.

developer.android.com/guide/publishing/app-signing.html

developer.android.com/guide/publishing/app-signing.html

6. 运行 6verifySigned.bat 以验证签名是否正常

6. run 6verifySigned.bat to verify the signing worked properly

7. 运行 7zipAlign.bat 来对齐 apk 文件.

7. run 7zipAlign.bat to align the apk file.

developer.android.com/guide/developing/tools/zipalign.html

developer.android.com/guide/developing/tools/zipalign.html

到此您已完成.如果您想在设备上测试它,请继续.

You are finished at this point. Continue on if you want to test it on a device.

8. 运行 8installAPK.bat 在 USB 连接的设备上安装 apk.

8. run 8installAPK.bat to install the apk on a usb connected device.

9. 如果要使用远程调试,请运行 9remoteDebugger.bat.

9. run 9remoteDebugger.bat if you want to use remote debugging.

我希望这对某人有所帮助.如果我忘记包含某些内容,请告诉我.另外,如果您知道更好的方法来做到这一点,请发表评论(例如如何将其组合成 1 个长时间暂停的 bat 文件...)

i hope this helps someone. let me know if i forgot to include something. also, if you know a better way to do this, please comment (such as how to combine this into 1 long pausing bat file...)

这篇关于重命名 APK 中的包名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆