Eclipse installation failed due to invalid APK file?

35,650

Solution 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.

Solution 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.

Solution 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.

Solution 4

Try this over ADB:

cd /data/local
mv tmp tmp-old
mkdir /mnt/sdcard/tmp
ln -s /mnt/sdcard/tmp ./tmp
Share:
35,650
AbbasS
Author by

AbbasS

Updated on July 09, 2022

Comments

  • AbbasS
    AbbasS almost 2 years

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

    Installation failed due to invalid APK file!