简体   繁体   English

Android - 使用 apktool 将项目构建到 APK 文件时出错

[英]Android - Error when building project to APK file using apktool

I have an APK file named: MyApp.apk.我有一个名为:MyApp.apk 的 APK 文件。 First I decode it using apktool:首先我使用 apktool 解码它:

apktool d MyApp.apk

It generates project folder: MyApp.它生成项目文件夹:MyApp。 Then I import it to Eclipse to edit it.然后我将它导入到 Eclipse 中进行编辑。
I create a new class as an Activity inside the MyApp project.我在 MyApp 项目中创建了一个新类作为 Activity。
After finishing, I export the project to an APK file using apktool again:完成后,我再次使用 apktool 将项目导出到 APK 文件:

apk b MyApp

It generates an APK file which I name Final_MyApp.apk.它生成一个 APK 文件,我将其命名为 Final_MyApp.apk。 After, I sign it.之后,我签字。
When I install Final_MyApp.apk using:当我使用以下命令安装 Final_MyApp.apk 时:

adb install Final_MyApp.apk

My application does not run.我的应用程序没有运行。 How can I fix it?我该如何解决?

adb install only installs your application on the device. adb install只会在设备上安装您的应用程序。
To start your application, you have to call the activity manager (am)要开始您的申请,您必须致电活动经理(上午)

adb shell am start -n com.package.name/com.package.name.ActivityName

See this post for more information: https://stackoverflow.com/a/4567928/1321873 .有关更多信息,请参阅此帖子: https : //stackoverflow.com/a/4567928/1321873

I think you cannot include your new activity into your android manifest file.我认为您不能将您的新活动包含在您的 android 清单文件中。 That's why your APK does not run.这就是您的 APK 无法运行的原因。

Also store your apk in C or D folder and try like this还将您的 apk 存储在 C 或 D 文件夹中并尝试这样

adb install C:\Final_MyApp.apk

When APK applications are built by apktool, there can be problems if the project folders or files do not use an 8 character file extension.当 APK 应用程序由 apktool 构建时,如果项目文件夹或文件不使用 8 个字符的文件扩展名,可能会出现问题。 There is no need for any version markers at all in either folders or filenames to get this error message.在文件夹或文件名中根本不需要任何版本标记来获取此错误消息。

Do you know how many bytes your app's "META-INF/" information should take?你知道你的应用程序的“META-INF/”信息应该占用多少字节? Each entry has 4 bytes!每个条目有 4 个字节! So what does that mean?那是什么意思呢? It means that one kilobyte of folder/file data will only take up two kilobytes on disk, but yet claim four megabytes when an application is built - wayyy too much space to use!这意味着 1 KB 的文件夹/文件数据只会在磁盘上占用 2 KB,但在构建应用程序时却会占用 4 兆字节 - 太多空间无法使用! Remember the APK meant for distribution needs to be lean and trim to save SDK device storage请记住,用于分发的 APK 需要精简和精简以节省 SDK 设备存储空间

or, An APK refers to an Android application package, and while there's no "apktool" we're aware of, the question likely refers to the apktool website.或者,一个 APK 是指一个 Android 应用程序包,虽然我们知道没有“apktool”,但问题可能是指 apktool 网站。 There are a number of errors that can generate such a message, but the one it sounds like you'll want is called W2OTA error.有许多错误可以生成这样的消息,但听起来您想要的错误称为 W2OTA 错误。 This is related to how APK files need three pieces of code (in addition to assets) in order for them to be converted properly.这与 APK 文件如何需要三段代码(除了资产之外)才能正确转换它们有关。 The three pieces of codes are: Dalvik Executable (.dex), compiled version of Android Resources (.apk), and Application Description file (.apk).三段代码分别是:Dalvik Executable(.dex)、Android资源编译版(.apk)、应用描述文件(.apk)。 You can follow tutorials on how edit these files and install them onto your phone using Simple Recovery Tool v1您可以遵循有关如何使用 Simple Recovery Tool v1 编辑这些文件并将它们安装到手机上的教程

Best,最好的,

Nathan Drake内森·德雷克

Essay Writer随笔作家

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

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