Android“Hello World”教程程序。错误:[解析错误] 解析包时出现问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2816086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android "Hello World" tutorial program. Error: [Parse Error] There is a problem parsing the package
提问by ConfusedDeveloper
Today I decided to start developing for the Android OS. I went on their website, downloaded all the required software (Eclipse, The Android SDK, ADT Plugin for Eclipse etc.). I followed the "Hello World" tutorial supplied (link text). I have it using the Android SDK 2.1.
The program worked almost flawlessly. It runs fine on the Android emulator, but doesn't install on any Android phones. I don't own an Android phone, so I had three of my friends try to install the program on theirs.
The phones we used were:
今天我决定开始为 Android 操作系统开发。我访问了他们的网站,下载了所有必需的软件(Eclipse、Android SDK、用于 Eclipse 的 ADT 插件等)。我遵循了提供的“Hello World”教程(链接文本)。我使用的是 Android SDK 2.1。该程序几乎完美无缺。它在 Android 模拟器上运行良好,但不能安装在任何 Android 手机上。我没有 Android 手机,所以我让我的三个朋友尝试在他们的手机上安装该程序。
我们使用的手机有:
- ROOTED G1 running 2.1
- Droid running 2.1
- Another Droid running 2.1
- ROOTED G1 运行 2.1
- 运行 2.1 的机器人
- 另一个运行 2.1 的 Droid
I emailed the .apk to myself in gmail, and accessed it via the Android emulator. It ran and installed the package just fine. However, when my friends tried to install it on their phones, they were all met with this error: "[Parse Error] There is a problem parsing the package"
我通过 gmail 将 .apk 通过电子邮件发送给自己,并通过 Android 模拟器访问它。它运行并安装了软件包就好了。但是,当我的朋友尝试在他们的手机上安装它时,他们都遇到了这个错误:“[解析错误]解析包时出现问题”
I'm wondering if anyone has any suggestions as to what may be wrong. Thanks for your help.
我想知道是否有人对可能出现的问题有任何建议。谢谢你的帮助。
采纳答案by Damien MATHIEU
How are you installing the package ?
You should :
你是如何安装软件包的?
你应该 :
- Install AppManager from the Android Market.
- Get the .apk file on your SD card.
- Start AppManager and click on the "menu button".
- Select "Install" and the application to install.
- 从 Android Market 安装 AppManager。
- 获取 SD 卡上的 .apk 文件。
- 启动 AppManager 并单击“菜单按钮”。
- 选择“安装”和要安装的应用程序。
If the application doesn't show up, select "Whole SD" to see all the SD card applications.
如果应用程序没有出现,请选择“整个 SD”以查看所有 SD 卡应用程序。
回答by Umesh Suryawanshi
don't worry. Its a little problem. I also spend one week behind this and finally I got the solution. Just go to you manifest.xml file and perform fallowing changes.
别担心。它的一个小问题。我也花了一个星期的时间,最后我得到了解决方案。只需转到 manifest.xml 文件并执行空闲更改即可。
//uses-sdk android:minSdkVersion="14"
Just change it to
只需将其更改为
//uses-sdk android:minSdkVersion="3"
Or any lower level sdk version that our device support. Try it. And reply, whether You satisfied or not.
或我们设备支持的任何较低级别的 sdk 版本。尝试一下。并回复,无论您是否满意。
回答by Aditya Prakarsa
Go to your manifest.xml and just delete the
转到您的 manifest.xml 并删除
uses-sdk android:minSdkVersion="14"
使用-sdk android:minSdkVersion="14"
回答by Jerry
I recently ran into the same problem. I solved it by porting an app from a Andriod SDK (4.0.3) to one supported by the phone I was deploying the app to (2.3.3).
我最近遇到了同样的问题。我通过将应用程序从 Andriod SDK (4.0.3) 移植到我正在将应用程序部署到 (2.3.3) 的手机支持的应用程序解决了这个问题。
回答by Steve Haley
You shouldn't have to use a custom app to install something. Simply trying it open it from the SD card (ok, so you need a file manager for that :p) or accessing directly the file via email really should work. There are two things to check:
您不必使用自定义应用程序来安装某些东西。只需尝试从 SD 卡打开它(好的,所以您需要一个文件管理器:p)或通过电子邮件直接访问文件确实应该可行。有两件事要检查:
- As I put in the comment, what's the package name you're using?
- Do any of those phones have the setting to allow applications from outside the market to be installed? It's done via settings -> applications. If none do, then the installation might not have been allowed because you probably didn't sign the app as a "finished app" - by default things are signed with a debug key.
- 正如我在评论中所说,您使用的包名称是什么?
- 这些电话中是否有任何设置允许安装来自市场以外的应用程序?这是通过设置-> 应用程序完成的。如果没有,则可能不允许安装,因为您可能没有将应用程序签名为“完成的应用程序” - 默认情况下,使用调试密钥签名。
Edit:
编辑:
I just Googled around, and it turns out a few other people have had this problem. However, in each case it has been solved in a different manner... In one case, using a 3rd party filebrowsing app solved the problem. In another case, the dev had renamed the .apk file after signing and exporting it, and apparently that was enough to break it for him. This doesn't make any sense to me though - I just tested it on my phone with three different versions: signed with the debug key, signed with a 'proper' key and signed with a proper key and then renamed. In each case the app was copied to my SD card, opened with Astro (a file browsing program), which in turn launched the built-in installer app. All three worked, so I don't know how the other guy had problems with renaming his .apk.
我刚刚用谷歌搜索了一下,结果发现其他一些人也遇到了这个问题。然而,在每种情况下,它都以不同的方式解决......在一种情况下,使用第 3 方文件浏览应用程序解决了问题。在另一个案例中,开发人员在签名和导出后重命名了 .apk 文件,显然这足以让他破坏它。不过,这对我来说没有任何意义 - 我只是在我的手机上用三个不同的版本测试了它:用调试密钥签名,用“正确”密钥签名,用正确密钥签名,然后重命名。在每种情况下,应用程序都被复制到我的 SD 卡上,用 Astro(一个文件浏览程序)打开,后者又启动了内置的安装程序应用程序。这三个都有效,所以我不知道另一个人在重命名他的 .apk 时有什么问题。
So... I don't know. Sorry :/ Maybe try installing it from a debug-key-signed apk, or maybe start another project from scratch and see if somehow your manifest file got corrupted.
所以……我不知道。抱歉:/也许尝试从调试密钥签名的 apk 安装它,或者从头开始另一个项目,看看您的清单文件是否以某种方式损坏。
To answer your comments:
回答您的意见:
- The package name is the com.example.helloandroidtwo style name. The apk name is just the name of the zip file (APKs are just zip files!) and shouldn't make a difference. Your package name looks fine, hmm.
- It turns out you did sign your application 'properly'. Generating a keystore like that makes it use a proper key rather than a debug one. I didn't think it'd make a difference, but it was worth checking. I don't bother signing my apps with a proper key until I actually put them on the Market.
- Taking API level 7 is fine since all your test phones are also running level 7 (v2.1). Normally you don't want to set the mininum version to 7 since that excludes the majority of users, but that shouldn't be your problem here. Just to be sure though, edit the project properties to set the target to be level 3. Unless you downloaded all the API levels when you started, you probably won't already have it. Download it using the AVD Manager in Eclipse.
- 包名称是 com.example.helloandroidtwo 样式名称。apk 名称只是 zip 文件的名称(APK 只是 zip 文件!),应该没有区别。你的包名看起来不错,嗯。
- 事实证明,您确实“正确”地签署了您的申请。生成这样的密钥库使其使用正确的密钥而不是调试密钥。我不认为它会有所作为,但值得检查。在我真正将它们投放市场之前,我不会用正确的密钥签署我的应用程序。
- 使用 API 级别 7 没问题,因为您所有的测试手机也都运行级别 7 (v2.1)。通常您不想将最小版本设置为 7,因为这排除了大多数用户,但这不应该是您的问题。不过为了确定,编辑项目属性以将目标设置为级别 3。除非您在开始时下载了所有 API 级别,否则您可能还没有它。使用 Eclipse 中的 AVD 管理器下载它。
回答by Roel Spilker
The easiest solution is to use the browser to access your gmail account via http://mail.google.comand the download the attachment using the link. After that, you can run the install, provided you enabled the installation of non-market applications.
最简单的解决方案是使用浏览器通过http://mail.google.com访问您的 Gmail 帐户,然后使用链接下载附件。之后,您可以运行安装,前提是您启用了非市场应用程序的安装。