2011-09-14 15 views
1

我要簽名的機器人.apk,我已經得到了以下配置文件設置在我pom.xml的Android行家的jarsigner,的jarsigner:嘗試重新命名X,但失敗了

<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 tutorial對於上述(另一類似的例子here我已經嘗試過,但效果相同),和我執行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>(如previous SO後的建議)以將文物移出,但這似乎沒有任何效果,可能是由於我沒有正確使用它。

有什麼建議嗎?

乾杯

編輯:如果我拿出從錯誤信息的命令,並運行,爲mypassword'*****',它工作正常....

+0

只要看看:丹尼斯·倫德伯格評論](http://jira.codehaus.org/browse /MJARSIGNER-13?focusedCommentId=332952&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-332952) –

回答

1

試過所有我能想到的,但無法讓maven-jarsigner-plugin進行操作,但是通過使用maven-jar-plugin,我能夠使用它來簽署我的應用程序。不幸的是,插件略有不推薦,它指的是使用jarsigner插件,但它爲我工作。

寫了一個tutorial here爲誰可能卡住在同一個問題上的任何人。

+1

要使您的商店密碼不在pom.xml中,可將它們存儲在您的Maven設置中文件中像這樣: 標誌爲mypass爲mypass

0

對我來說,解決辦法是不使用的目標「驗證」,並沒有使用這樣的語句: <removeExistingSignatures>true</removeExistingSignatures>