我想签署一个 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
要签署 a,它不应该只是最终.apk
签署的吗?
我尝试添加一个<destDir>
(如之前的 SO帖子所建议的)以将人工制品移出,但这似乎没有任何效果,可能是因为我没有正确使用它。
有什么建议么?
干杯
编辑:如果我从错误消息中取出命令并运行它,代替它'*****'
,mypassword
它工作正常......