I use Eclipse for develop android apps, but when run projects see this error:
Installation failed due to invalid APK file!
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.
Try this over ADB:
cd /data/local
mv tmp tmp-old
mkdir /mnt/sdcard/tmp
ln -s /mnt/sdcard/tmp ./tmp
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
I am sure this is the version problem. First check whether your emulator/phone is having correct version that you are developing for.
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!
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.