Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid LOC header Maven compilation error for Android support-v4

Tags:

android

maven

I am getting compilation fail error while maven build my pom.xml file.

Compilation error is:

error reading C:\Users\amrit\.m2\repository\com\google\android\support-v4\r6\support-v4-r6.jar; invalid LOC header (bad signature).

Does anyone know how to fix this problem? Below is my pom.xml file:

<project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyListReq</groupId>
<artifactId>MyListReq</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AtosList</name>


<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <version>r6</version>
    </dependency>

</dependencies>



<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk1.7.0_03\bin\javac.exe
                </executable>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <path>${env.ANDROID_HOME}</path>
                    <platform>17</platform>
                </sdk>
            </configuration>
            <extensions>true</extensions>
        </plugin>

    </plugins>
</build>

I am not able to fix this problem. Any sort of help will be appreciated.

like image 652
Amrit Pal Singh Avatar asked Jan 10 '14 10:01

Amrit Pal Singh


1 Answers

That error means that the locally cached .jar is corrupt. Please delete C:\Users\amrit.m2\repository\com\google\android\support-v4\r6\support-v4-r6.jar and allow Maven to re-download the file.

If the error still occurs then the source repository where Maven is downloading the .jar from is bad. Consider switching Maven repositories or changing to a different version of the library - r7 (if you can), for example:

<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>support-v4</artifactId>
    <version>r7</version>
</dependency>

Or manually downloading the .jar from a Maven repository like http://mvnrepository.com/artifact/com.google.android/support-v4/r6

Note: Google aren't responsible for adding those libraries to the Maven repositories, which is why a) they are not kept up to date and b) why (sometimes) they are corrupt - see Android support library setup with maven

like image 58
andyb Avatar answered Sep 30 '22 13:09

andyb