我想签署一个android .apk,我在我的pom.xml中设置了以下配置文件
<profiles>
<profile><!-- release profile. uses keystore defined in keystore.* properties. signs and zipaligns the app to the target folder-->
<id>release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<defaultGoal>install</defaultGoal>
<finalName>${project.artifactId}-${project.version}</finalName>
<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>
<includes>
<include>
${project.build.directory}/target/${project.artifactId}-${project.version}.apk
</include>
</includes>
<keystore>my-release-key.keystore</keystore>
<storepass>mypasshere</storepass>
<keypass>mypasshere</keypass>
<alias>mykeystore</alias>
<verbose>true</verbose>
<!--<destDir>gen</destDir>-->
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>maven-android-plugin</artifactId>
<configuration>
<zipalign>
<verbose>true</verbose>
<skip>false</skip>
<!-- defaults to true -->
<inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
<outputApk>${project.build.directory}/MyApp_v${project.version}.apk</outputApk>
</zipalign>
<sign>
<debug>false</debug>
</sign>
</configuration>
<executions>
<execution>
<id>zipalign</id>
<phase>verify</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>我在上面使用了Novoda教程 (我尝试过的另一个类似的示例这里,但效果相同),并且正在执行mvn clean install -Prelease,但是我得到了以下错误:
[INFO] jarsigner: attempt to rename C:\android-projects\jameselsey_andsam_branch_mavenbranch\target\LanguageSelection-1.0.0-SNAPSHOT.jar to C:\android-projects\jameselsey_ands
am_branch_mavenbranch\target\LanguageSelection-1.0.0-SNAPSHOT.jar.orig failed
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed executing 'cmd.exe /X /C "C:\development\tools\Java\jdk1.6.0_20\jre\..\bin\jarsigner.exe -verbose -keystore my-release-key.keystore -storepass '*****' -keypass '
*****' C:\android-projects\jameselsey_andsam_branch_mavenbranch\target\LanguageSelection-1.0.0-SNAPSHOT.jar mykeystore"' - exitcode 1
[INFO] ------------------------------------------------------------------------据我所知,重命名失败是因为那个特定的文件在打包阶段仍然在使用,所以它基本上是锁定的。
我该怎么纠正呢?我不完全确定为什么要对.jar进行签名,难道不应该仅仅是最终的.apk才能得到签名吗?
我尝试添加一个<destDir> (如上一次帖子所建议的)来移出这些手工艺品,但这似乎没有任何效果,可能是因为我没有正确地使用它。
有什么建议吗?
干杯
编辑:如果我从错误消息中取出命令并运行该命令,以'*****'代替mypassword,它可以很好地工作.
发布于 2011-09-15 17:32:41
尝试了我所能想到的一切,但是无法让maven-jarsigner-plugin操作,但是通过使用maven-jar-plugin,我可以用它来对我的应用程序进行签名。不幸的是,这个插件被略为反对,它指的是使用jarsigner插件,但它对我有效。
为在这个问题上可能陷入困境的其他人写了一个这里的教程。
发布于 2011-09-29 05:27:22
对我来说,解决方案是不使用目标“验证”,也不使用这样的语句:<removeExistingSignatures>true</removeExistingSignatures>
https://stackoverflow.com/questions/7421710
复制相似问题