2

我使用这些 Maven 设置来签署我的应用程序:

<profiles>
    <profile>
        <id>sign</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>/home/markus/.android/release.keystore</keystore>
                                <storepass>mypass</storepass>
                                <keypass>mypass</keypass>
                                <alias>androidreleasekey</alias>
                                <arguments>
                                    <argument>-sigalg</argument>
                                    <argument>MD5withRSA</argument>
                                    <argument>-digestalg</argument>
                                    <argument>SHA</argument>
                                </arguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <inherited>true</inherited>
                    <configuration>
                        <sign>
                            <debug>false</debug>
                        </sign>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

我从这里获取了这些信息:http ://code.google.com/p/maven-android-plugin/wiki/SigningAPKWithMavenJarsigner 。但是在将应用程序部署到我的手机(Android 2.1)和手机上的“应用程序未安装”时,我总是收到此错误消息“INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION”。我尝试了这里描述的这些建议(甚至更多):'App not Installed' Error on Android。但是这些解决方案都不适合我。LogCat 向我显示此错误:

12-27 21:01:28.177: W/PackageParser(1165): java.lang.SecurityException: /data/app/vmdl60304.tmp failed verification of META-INF/ANDROIDR.SF
12-27 21:01:28.177: W/PackageParser(1165):  at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:350)
12-27 21:01:28.177: W/PackageParser(1165):  at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:273)
12-27 21:01:28.177: W/PackageParser(1165):  at java.util.jar.JarFile.getInputStream(JarFile.java:416)
12-27 21:01:28.177: W/PackageParser(1165):  at android.content.pm.PackageParser.loadCertificates(PackageParser.java:317)
12-27 21:01:28.177: W/PackageParser(1165):  at android.content.pm.PackageParser.collectCertificate

在修补了大约半天后,我发现上面显示的这个配置文件以某种方式破坏了签名。当我将此部分添加到我通常的构建部分时:

    <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <inherited>true</inherited>
        <configuration>
            <sign>
                <debug>false</debug>
            </sign>
        </configuration>
    </plugin>

在Maven 手动安装和签名应用程序时不签署应用程序,它可以工作:

jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore /home/markus/.android/release.keystore myapp-1.0.apk androidreleasekey

我很高兴我能以某种方式管理它,但有人可以向我解释为什么它不适用于我智能手机上的 Maven 签名配置文件吗?有趣的是:我总是能够在我的平板电脑 Android 3.0 上安装它,即使使用 Maven 也是如此。为什么它可以在 Android 3.0 Galaxy Tab 上使用 Maven 而不是在我的 Android 2.1 手机上?

顺便说一句:调试部署总是有效的,即使在我的智能手机上也是如此。

4

0 回答 0