无法读取 AndroidManifest.xml

发布于 2024-11-19 17:42:56 字数 3392 浏览 1 评论 0原文

我已经完成了一个 Android 应用程序,现在正尝试在发布模式下对其进行签名。我已经生成了一个密钥库,并更新了我的构建属性以检查适当的密钥库文件和别名。一切都编译得很好,我得到了一个很好的 apk 文件。但是,当我尝试在移动设备上安装此程序时,我收到“无法读取 AndroidManifest.xml”错误。根据 Android 文档,通过构建属性提供密钥库/别名将自动签名并对齐最终的 apk 文件。

如果我将 apk 文件重命名为 zip,我确实可以看到所有内容都在那里。我不确定采取什么步骤来解决这个问题。我正在通过命令行完成所有操作,而不是使用 Eclipse。如果我通过调试版本安装我的应用程序,它就可以正常工作。

这是 ant 的输出([[PASSWORD]] 是我的密码,MYALIAS 是我的别名)。 “CApp”是主要活动。

> D:\Development\Projects\Dash>ant release Buildfile:
> D:\Development\Projects\Dash\build.xml
>     [setup] Android SDK Tools Revision 11
>     [setup] Project Target: Android 2.1-update1
>     [setup] API level: 7
>     [setup]
>     [setup] ------------------
>     [setup] Resolving library dependencies:
>     [setup] No library dependencies.
>     [setup]
>     [setup] ------------------
>     [setup]
>     [setup]
>     [setup] Importing rules file: tools\ant\main_rules.xml
> 
> -set-release-mode:
>      [echo] *************************************************
>      [echo] ****  Android Manifest has debuggable=true   ****
>      [echo] **** Doing DEBUG packaging with RELEASE keys ****
>      [echo] *************************************************
> 
> -release-obfuscation-check:
> 
> -pre-build:
> 
> -dirs:
>      [echo] Creating output directories if needed...
>     [mkdir] Created dir: D:\Development\Projects\Dash\bin
>     [mkdir] Created dir: D:\Development\Projects\Dash\gen
>     [mkdir] Created dir: D:\Development\Projects\Dash\bin\classes
> 
> -aidl:
>      [echo] Compiling aidl files into Java classes...
> 
> -renderscript:
>      [echo] Compiling RenderScript files into Java classes and RenderScript bytecode...
> 
> -resource-src:
>      [echo] Generating R.java / Manifest.java from the resources...
> 
> -pre-compile:
> 
> compile:
>     [javac] D:\Development\Libraries\android-sdk-windows\tools\ant\main_rules.xml:384:
> warning: 'includeantruntime' was not set, defaulting to
> build.sysclasspat h=last; set to false for repeatable builds
>     [javac] Compiling 14 source files to D:\Development\Projects\Dash\bin\classes
> 
> -post-compile:
> 
> -obfuscate:
> 
> -dex:
>      [echo] Converting compiled files and external libraries into D:\Development\Projects\Dash\bin\classes.dex...
> 
> -package-resources:
>      [echo] Packaging resources
>      [aapt] Creating full resource package...  [aapt.exe] Warning: AndroidManifest.xml already defines debuggable (in
> http://schemas.android.com/apk/res/android); using existing value in
> manifest.
> 
> -package-release: [apkbuilder] Creating CApp-unsigned.apk for release...
> 
> -release-prompt-for-password:
>     [input] Please enter keystore password (store:1.keystore): [[PASSWORD]]
>     [input] Please enter password for alias 'MYALIAS': [[PASSWORD]]
> 
> -release-nosign:
> 
> release:
>      [echo] Signing final apk...   [signjar] Signing JAR: D:\Development\Projects\Dash\bin\CApp-unsigned.apk to
> D:\Development\Projects\Dash\bin\CApp-unaligned.apk as MYALIAS
>      [echo] Running zip align on final apk...
>      [echo] Release Package: D:\Development\Projects\Dash\bin\CApp-release.apk
> 
> BUILD SUCCESSFUL Total time: 16 seconds

I have finished up an Android app and I am attempting to sign it now in release mode. I have generated a keystore, and have updated my built properties to check the appropriate keystore file and alias. Everything compiles just fine, and I am presented with a nice apk file. However, when I attempt to install this on a mobile device I receive a 'Unable to read AndroidManifest.xml' error. According to the Android docs, providing the keystore / alias via the build properties will automatically sign and align the final apk file.

If I rename the apk file to a zip, I can indeed see everything is there. I am unsure of what steps to take to solve this issue. I am doing everything command line, and not using Eclipse. If I install my app via debug release, it works just fine.

Here is the output of ant ([[PASSWORD]] is my password, and MYALIAS is my alias). 'CApp' is the primary activity.

> D:\Development\Projects\Dash>ant release Buildfile:
> D:\Development\Projects\Dash\build.xml
>     [setup] Android SDK Tools Revision 11
>     [setup] Project Target: Android 2.1-update1
>     [setup] API level: 7
>     [setup]
>     [setup] ------------------
>     [setup] Resolving library dependencies:
>     [setup] No library dependencies.
>     [setup]
>     [setup] ------------------
>     [setup]
>     [setup]
>     [setup] Importing rules file: tools\ant\main_rules.xml
> 
> -set-release-mode:
>      [echo] *************************************************
>      [echo] ****  Android Manifest has debuggable=true   ****
>      [echo] **** Doing DEBUG packaging with RELEASE keys ****
>      [echo] *************************************************
> 
> -release-obfuscation-check:
> 
> -pre-build:
> 
> -dirs:
>      [echo] Creating output directories if needed...
>     [mkdir] Created dir: D:\Development\Projects\Dash\bin
>     [mkdir] Created dir: D:\Development\Projects\Dash\gen
>     [mkdir] Created dir: D:\Development\Projects\Dash\bin\classes
> 
> -aidl:
>      [echo] Compiling aidl files into Java classes...
> 
> -renderscript:
>      [echo] Compiling RenderScript files into Java classes and RenderScript bytecode...
> 
> -resource-src:
>      [echo] Generating R.java / Manifest.java from the resources...
> 
> -pre-compile:
> 
> compile:
>     [javac] D:\Development\Libraries\android-sdk-windows\tools\ant\main_rules.xml:384:
> warning: 'includeantruntime' was not set, defaulting to
> build.sysclasspat h=last; set to false for repeatable builds
>     [javac] Compiling 14 source files to D:\Development\Projects\Dash\bin\classes
> 
> -post-compile:
> 
> -obfuscate:
> 
> -dex:
>      [echo] Converting compiled files and external libraries into D:\Development\Projects\Dash\bin\classes.dex...
> 
> -package-resources:
>      [echo] Packaging resources
>      [aapt] Creating full resource package...  [aapt.exe] Warning: AndroidManifest.xml already defines debuggable (in
> http://schemas.android.com/apk/res/android); using existing value in
> manifest.
> 
> -package-release: [apkbuilder] Creating CApp-unsigned.apk for release...
> 
> -release-prompt-for-password:
>     [input] Please enter keystore password (store:1.keystore): [[PASSWORD]]
>     [input] Please enter password for alias 'MYALIAS': [[PASSWORD]]
> 
> -release-nosign:
> 
> release:
>      [echo] Signing final apk...   [signjar] Signing JAR: D:\Development\Projects\Dash\bin\CApp-unsigned.apk to
> D:\Development\Projects\Dash\bin\CApp-unaligned.apk as MYALIAS
>      [echo] Running zip align on final apk...
>      [echo] Release Package: D:\Development\Projects\Dash\bin\CApp-release.apk
> 
> BUILD SUCCESSFUL Total time: 16 seconds

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文