2014-11-25 46 views
0

我一直在關注互聯網上的一些帖子和資源,讓Maven簽署我的android apk文件。但是當我驗證apk文件是否使用jarsigner簽名時,它說「jar是未簽名的」。然而,zip對齊似乎正在工作,並且maven控制檯輸出確實會說「爲apk啓用發佈版本」。Android Maven構建不簽署應用程序

我的pom.xml的構建部分看起來如下:

<build> 
     <finalName>${project.artifactId}</finalName> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-jarsigner-plugin</artifactId> 
        <executions> 
         <execution> 
          <id>signing</id> 
          <goals> 
           <goal>sign</goal> 
           <goal>verify</goal> 
          </goals> 
          <phase>package</phase> 
          <inherited>true</inherited> 
          <configuration> 
           <removeExistingSignatures>true</removeExistingSignatures> 
           <archiveDirectory/> 
           <includes> 
            <include>${project.build.directory}/${project.artifactId}.apk</include> 
           </includes> 
           <keystore>c:/java/android/my.keystore</keystore> 
           <alias>myalias</alias> 
           <storepass>mypass</storepass> 
           <keypass>mypass</keypass> 
           <verbose>true</verbose> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
       <plugin> 
        <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
        <artifactId>android-maven-plugin</artifactId> 
        <version>${android.plugin.version}</version> 
        <configuration> 
         <release>true</release> 
         <mergeManifests>true</mergeManifests> 
         <sign> 
          <debug>false</debug> 
         </sign> 
         <zipalign> 
          <verbose>true</verbose> 
          <inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk> 
          <outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk</outputApk> 
          <skip>false</skip> 
         </zipalign> 
        </configuration> 
        <executions> 
         <execution> 
          <id>alignApk</id> 
          <phase>package</phase> 
          <goals> 
           <goal>zipalign</goal> 
          </goals> 
         </execution> 
        </executions> 
        <extensions>true</extensions> 
       </plugin> 
       <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> 
       <plugin> 
        <groupId>org.eclipse.m2e</groupId> 
        <artifactId>lifecycle-mapping</artifactId> 
        <version>1.0.0</version> 
        <configuration> 
         <lifecycleMappingMetadata> 
          <pluginExecutions> 
           <pluginExecution> 
            <pluginExecutionFilter> 
             <groupId> 
              com.jayway.maven.plugins.android.generation2 
             </groupId> 
             <artifactId> 
              android-maven-plugin 
             </artifactId> 
             <versionRange> 
              [3.8.0,) 
             </versionRange> 
             <goals> 
              <goal>consume-aar</goal> 
             </goals> 
            </pluginExecutionFilter> 
            <action> 
             <ignore></ignore> 
            </action> 
           </pluginExecution> 
          </pluginExecutions> 
         </lifecycleMappingMetadata> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
       <artifactId>android-maven-plugin</artifactId> 
       <configuration> 
        <sdk> 
         <platform>15</platform> 
        </sdk> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

任何想法,爲什麼的jarsigner會說我的apk未與上述pom.xml的簽署?

回答

0

我設法通過刪除<pluginManagement>元素標記來實現它,因此<plugins>元素不嵌套在<pluginManagement>元素中。

現在我的apk文件已經簽名。