maven-jarsigner-plugin: impossible de signer jar: java.util.zip.ZipException: entrée non valide taille compressée


Depuis la mise à jour d'un très ancien projet vers android-maven-plugin version 4.1.0 J'ai l'erreur suivante lors de la signature de mon apk pour la publication:

Impossible de signer jar: java.util.zip.ZipException: entrée non valide taille compressée

Ma configuration de signature maven dans pom:

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <version>1.2</version>
            <executions>
              <execution>
                <id>signing</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>package</phase>
                <inherited>true</inherited>
                <configuration>
                  <archiveDirectory></archiveDirectory>
                  <includes>
                    <include>target/*.apk</include>
                  </includes>
                  <keystore>keystore/keystore</keystore>
                  <storepass>sjdjjfdf</storepass>
                  <keypass>sjdjjfdf</keypass>
                  <alias>v110</alias>
                  <arguments>
                    <argument>-sigalg</argument>
                    <argument>MD5withRSA</argument>
                    <argument>-digestalg</argument>
                    <argument>SHA1</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.simpligility.maven.plugins</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <sign>
                <debug>false</debug>
              </sign>
              <zipalign>
                <skip>false</skip>
                <verbose>true</verbose>
                <inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
                <outputApk>${project.build.directory}/${project.artifactId}-release-v${project.version}.apk</outputApk>
              </zipalign>
            </configuration>
            <executions>
              <execution>
                <id>alignApk</id>
                <phase>install</phase>
                <goals>
                  <goal>zipalign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

, Après enquête, j'ai découvert que:

  • La taille différente était due au dossier META-INF dans l'apk de débogage généré.
  • Ceci était dû à une signature automatique du débogage apk.

Quelqu'un A eu ce problème et trouver une solution pour elle?

Article connexe, mais non lié à pom et maven config:

Jarsigner: impossible de signer jar: java.util.zip.ZipException: entrée non valide taille compressée (attendu 463 mais obtenu 465 octets)

Author: Community, 2015-03-12

1 answers

Après avoir cherché à supprimer les fichiers META-INF de la génération jar dans le profil de publication, j'ai découvert que la solution la plus simple consiste à ajouter <removeExistingSignatures>true</removeExistingSignatures> à maven-jarsigner-plugin config:

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <version>1.2</version>
            <executions>
              <execution>
                <id>signing</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>package</phase>
                <inherited>true</inherited>
                <configuration>
                  <!-- Remove debug signature added to the apk automatically since x android plugin version -->
                  <removeExistingSignatures>true</removeExistingSignatures>
                  <archiveDirectory></archiveDirectory>
                  <includes>
                    <include>target/*.apk</include>
                  </includes>
                  <keystore>keystore/keystore</keystore>
                  <storepass>sjdjjfdf</storepass>
                  <keypass>sjdjjfdf</keypass>
                  <alias>v110</alias>
                  <arguments>
                    <argument>-sigalg</argument>
                    <argument>MD5withRSA</argument>
                    <argument>-digestalg</argument>
                    <argument>SHA1</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.simpligility.maven.plugins</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <sign>
                <debug>false</debug>
              </sign>
              <zipalign>
                <skip>false</skip>
                <verbose>true</verbose>
                <inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
                <outputApk>${project.build.directory}/${project.artifactId}-release-v${project.version}.apk</outputApk>
              </zipalign>
            </configuration>
            <executions>
              <execution>
                <id>alignApk</id>
                <phase>install</phase>
                <goals>
                  <goal>zipalign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
 1
Author: L. G., 2015-03-12 10:13:24