Eclipse installation failed due to invalid APK file?

♀尐吖头ヾ 提交于 2020-01-09 19:33:11

问题


I use Eclipse for develop android apps, but when run projects see this error:

Installation failed due to invalid APK file!


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


Try this over ADB:

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



回答5:


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




回答6:


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.




回答7:


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.




回答8:


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




回答9:


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



回答10:


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!



来源:https://stackoverflow.com/questions/7998101/eclipse-installation-failed-due-to-invalid-apk-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!