由于 APK 文件无效,Eclipse 安装失败?
我使用 Eclipse 开发 Android 应用程序,但是在运行项目时看到此错误:
由于 APK 文件无效而安装失败!
I use Eclipse for develop android apps, but when run projects see this error:
Installation failed due to invalid APK file!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
就我而言,这是由我的库中包含的 .jar 文件中的错误引起的。 .jar 文件是我创建的,因此我能够修复它。以下是问题如何开始以及我如何解决它的详细信息:
修复它时
包含不属于 src 文件夹的所有文件会导致项目和 .jar 中出现一些重复:
这导致 .apk 无效。希望这对某人有帮助。注意:只有当您有自己更改和编译的库文件并且犯了与我包含不需要的文件夹时相同的错误时,此解决方案才有效。
In my case this was caused by errors in a .jar file included my library. The .jar file was one I created and so I was able to fix it. Here is a breakdown of how the problem started and how I fixed it:
to fix it:
Having included all the files that were not part of the src folder caused a few duplicates in the project and .jar:
This caused the .apk to be invalid. Hope this helps someone. NOTE: this solution will only work if you have library files that you have changed and compiled yourself and have made the same mistake as I did when I included folders that were not needed.
我们看到“无效的 APK 文件”错误的最常见原因之一是由于无意中更改了
AndroidManifest.xml
配置,导致在您的设备上安装重复的 APK 文件。情况1:版本问题。提高您的最低和目标sdk版本,然后重试。
情况 2:包不匹配。
AndroidManifest.xml
中的包名称与您的 Activity 关联的实际包不匹配。解决此问题的三个步骤:
步骤 1. 从
AndroidManifest.xml
检查头文件。步骤 2. 确认 src 文件夹中的包名称与步骤 1 中验证的包名称完全相同。
例如
com.yourdomain.yourapp
步骤 3. 从启动器活动中检查包包含声明(例如
MainActivity.java
):如果上述解决方案不起作用,请发布您的 Logcat 以获得进一步帮助。
One of the most common reasons we see "Invalid APK file" error is due to inadvertently changed
AndroidManifest.xml
configuration, which results in installing duplicated APK files on your device.Posibility 1: version problem. Make your minimum and target sdk version higher and try again.
Posibility 2: package mistmatching. Package name in
AndroidManifest.xml
does not match with the actual package that your activity is associated with.Three steps to solve this problem:
Step 1. Check your header file from your
AndroidManifest.xml
.Step 2. Confirm that your package name in your src folder is exactly the same as the one you verified in Step 1.
e.g.
com.yourdomain.yourapp
Step 3. Check your package inclustion statement from your launcher activity (e.g.
MainActivity.java
):If the aforementioned solutions are not working, please post your Logcat for further assist.
完全同意@melvkim 的回答。要补充一件事。
另请确保您的包名称中没有使用禁用字符。例如:
包名称错误
com.domain.365days
- 包名称的任何部分都不能以数字 (...)com.domain._365days< /code> - (...) 也不是特殊字符
正确的包名称
com.domain.days365
- 包名称的所有部分均以字母开头请参阅您的 logcat非常仔细。 Eclipse IDE 可能不会显示任何错误或警告,但 logcat 会。
Totally agree with @melvkim answer. One thing to add.
Also please make sure that you do not use forbidden characters in your package name. E.g.:
Wrong package names
com.domain.365days
- you cant start any part of package name with a digit (...)com.domain._365days
- (...) nor a special characterCorrect package names
com.domain.days365
- start all parts of your package name with a letterPlease see your logcat very carefully. Eclipse IDE might not show any error or warning, but logcat will.
通过 ADB 尝试一下:
Try this over ADB:
我确定这是版本问题。首先检查您的模拟器/手机是否具有您正在开发的正确版本。
I am sure this is the version problem. First check whether your emulator/phone is having correct version that you are developing for.
对我来说,这是导致此错误的另一个问题:
我的项目正在使用嵌入到 APK 中的一些本机 JNI 库。为了在测试期间节省一些空间,我禁用了 lib\armeabi 版本,只留下较新的 lib\armeabi-v7a 变体。在较新的设备上一切正常,但在较旧的 G1 上测试却导致了此错误。
For me it was a different problem causing this error:
My project was using some native JNI libraries embedded to the APK. To save some space during tests, I disabled the lib\armeabi version, leaving only the newer lib\armeabi-v7a variant. All went fine on newer devices, but testing it on the older G1 resulted in this error.
检查手机或模拟器上的平台版本(取决于您测试的位置)必须与您在 AndroidManifest.xml 中提到的版本相同或更高。
Check your Platform version on Phone or Emulator (depend where you're testing ) must be same or greater then the version you mentioned in your AndroidManifest.xml.
就我而言,我通过更改 AndroidManifest.xml 解决了这个问题,
我从 更改
为
,因为 eclipse 给了我一个警告,不针对最新版本的 Android。
我正在使用最新的 Eclipse SDK v23
我的设备是 Nexus 7 2012 KitKat 4.4.4
In my case, I solved the problem by changing my AndroidManifest.xml
I changed from
to
because eclipse gave me an warning for nor targeting the latest version of Android.
I'm using the latest Eclipse SDK v23
and my device is Nexus 7 2012 KitKat 4.4.4
就我而言,问题是由于 Android 清单文件和项目构建目标 API 级别不匹配,
我将 targetSdkVersion 从 19 更改为 21。
另外,通过下面给出的步骤
更改目标 sdk 版本
In my case, the issue was due to mis-match in the Android manifest file and Project Build Target API Level
I changed from targetSdkVersion from 19 to 21.
Also, by changing the target sdk version through the steps
given below
对我来说,问题是我使用了错误的感兴趣文件路径。也就是说,apk文件不存在!为什么这个该死的东西不能直接告诉我它找不到文件?啊!啊好吧。也许这会帮助别人。仔细检查以确保您的文件路径正确!
For me, the problem was that I was using the wrong path to the file of interest. In other words, the apk file did not exist! Why couldn't the darn thing just tell me that it couldn't find a file? Argh! Ah well. Maybe this will help someone else. Double check to make sure that your path to the file is correct!