Eclipse installation failed due to invalid APK file?

前端 未结 10 1900
半阙折子戏
半阙折子戏 2020-12-15 11:29

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

Installation failed due to invalid APK file!

相关标签:
10条回答
  • 2020-12-15 11:43

    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.

    0 讨论(0)
  • 2020-12-15 11:44

    Try this over ADB:

    cd /data/local
    mv tmp tmp-old
    mkdir /mnt/sdcard/tmp
    ln -s /mnt/sdcard/tmp ./tmp
    
    0 讨论(0)
  • 2020-12-15 11:46

    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

    0 讨论(0)
  • 2020-12-15 11:47

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

    0 讨论(0)
  • 2020-12-15 11:50

    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!

    0 讨论(0)
  • 2020-12-15 11:52

    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.

    0 讨论(0)
提交回复
热议问题