由于 APK 文件无效,Eclipse 安装失败?

发布于 2024-12-13 09:56:29 字数 106 浏览 1 评论 0原文

我使用 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 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

以往的大感动 2024-12-20 09:56:29

就我而言,这是由我的库中包含的 .jar 文件中的错误引起的。 .jar 文件是我创建的,因此我能够修复它。以下是问题如何开始以及我如何解决它的详细信息:

  • 我对另一个项目(不是安装失败的项目)进行了更改
  • 导出到 .jar 包含项目中的所有文件(这是错误)
  • 生成的 .jar替换了我的项目中已包含的文件
  • 发生错误

修复它时

  • :重新导出的 .jar 文件,仅包括
  • 重新构建和安装的 src 文件夹。

包含不属于 src 文件夹的所有文件会导致项目和 .jar 中出现一些重复:

  • 示例:多个 androidmanifest.xml 文件,一个位于本地,一个位于 .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:

  • I made changes to another project(not the project that failed to install)
  • Exported to a .jar included ALL files in project(which was the mistake)
  • the resulting .jar replaced the one already included in my project
  • Errors occurred

to fix it:

  • Re-exported .jar file including only the src folder
  • re-built and installed just fine.

Having included all the files that were not part of the src folder caused a few duplicates in the project and .jar:

  • Example: multiple androidmanifest.xml files one local and one inside .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.

心凉怎暖 2024-12-20 09:56:29

我们看到“无效的 APK 文件”错误的最常见原因之一是由于无意中更改了 AndroidManifest.xml 配置,导致在您的设备上安装重复的 APK 文件。

情况1:版本问题。提高您的最低和目标sdk版本,然后重试。

情况 2:包不匹配。AndroidManifest.xml 中的包名称与您的 Activity 关联的实际包不匹配。

解决此问题的三个步骤:

步骤 1. 从 AndroidManifest.xml 检查头文件。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourdomain.yourapp"
    android:versionCode="1"
    android:versionName="1.0" >

步骤 2. 确认 src 文件夹中的包名称与步骤 1 中验证的包名称完全相同。

例如 com.yourdomain.yourapp

步骤 3. 从启动器活动中检查包包含声明(例如 MainActivity.java):

package com.yourdomain.yourapp;

如果上述解决方案不起作用,请发布您的 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.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourdomain.yourapp"
    android:versionCode="1"
    android:versionName="1.0" >

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):

package com.yourdomain.yourapp;

If the aforementioned solutions are not working, please post your Logcat for further assist.

电影里的梦 2024-12-20 09:56:29

完全同意@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 character

Correct package names

  • com.domain.days365 - start all parts of your package name with a letter

Please see your logcat very carefully. Eclipse IDE might not show any error or warning, but logcat will.

静谧幽蓝 2024-12-20 09:56:29

通过 ADB 尝试一下:

cd /data/local
mv tmp tmp-old
mkdir /mnt/sdcard/tmp
ln -s /mnt/sdcard/tmp ./tmp

Try this over ADB:

cd /data/local
mv tmp tmp-old
mkdir /mnt/sdcard/tmp
ln -s /mnt/sdcard/tmp ./tmp
等风也等你 2024-12-20 09:56:29

我确定这是版本问题。首先检查您的模拟器/手机是否具有您正在开发的正确版本。

I am sure this is the version problem. First check whether your emulator/phone is having correct version that you are developing for.

£烟消云散 2024-12-20 09:56:29

对我来说,这是导致此错误的另一个问题:

我的项目正在使用嵌入到 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.

清醇 2024-12-20 09:56:29

检查手机或模拟器上的平台版本(取决于您测试的位置)必须与您在 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.

送你一个梦 2024-12-20 09:56:29

就我而言,我通过更改 AndroidManifest.xml 解决了这个问题,

我从 更改

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="20" />

,因为 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

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />

to

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="20" />

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

笛声青案梦长安 2024-12-20 09:56:29

就我而言,问题是由于 Android 清单文件和项目构建目标 API 级别不匹配,

我将 targetSdkVersion 从 19 更改为 21。

另外,通过下面给出的步骤更改目标 sdk 版本

  1. 右键单击​​项目名称
  2. 选择属性
  3. 将“项目构建目标”更改为 API 级别 21

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 stepsgiven below

  1. right click on project name
  2. select properties
  3. change "Project Build Target" to API Level 21
画▽骨i 2024-12-20 09:56:29

对我来说,问题是我使用了错误的感兴趣文件路径。也就是说,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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文