2013-01-07 24 views
0

我們正在爲我的Android應用程序進行尺寸優化。Android壓縮資源不會改變APK的尺寸

但是,在我們對資源文件夾的大小進行了大幅縮減後,將其減少了8MB,當我編譯(使用maven)時,應用程序的大小僅減少了0.1mb。

有人可以解釋爲什麼會發生這種情況嗎?

我zipaligning,但多數民衆贊成在所有。

這裏是POM

<build> 

    <plugins> 
     <plugin> 
      <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
      <artifactId>android-maven-plugin</artifactId> 
      <version>3.2.0</version> 
      <extensions>true</extensions> 

      <configuration> 
       <!-- replace resources with target specific --> 


       <renameManifestPackage>${customerPackage}</renameManifestPackage> 
       <resourceOverlayDirectory>${customerResources}</resourceOverlayDirectory> 

       <sign> 
        <debug>false</debug> 
       </sign> 
        <manifest> 
        <versionCodeAutoIncrement>true</versionCodeAutoIncrement> 
        </manifest> 
        <zipalign> 
        <inputApk>${project.build.directory}/${project.build.finalName}.apk</inputApk> 
        <outputApk>${project.build.directory}/outputfile.apk</outputApk> 
       </zipalign> 

       <proguard> 
        <skip>true</skip> 
       </proguard> 

       <sdk> 
        <!-- platform or api level (api level 4 = platform 1.6)--> 
        <platform>17</platform> 
       </sdk> 
       <assetsDirectory>${project.basedir}/${customerAssets}</assetsDirectory> 
       <resourceDirectory>${project.basedir}/res</resourceDirectory> 
      </configuration> 

      <executions> 
       <execution> 
        <id>manifestUpdate</id> 
        <phase>process-resources</phase> 
        <goals> 
         <goal>manifest-update</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>alignApk</id> 
        <phase>package</phase> 
        <goals> 
         <goal>zipalign</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

     <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>../certificates/mycertificate.keystore</keystore> 
         <storepass>*******</storepass> 
         <keypass>******</keypass> 
         <alias>myalias</alias> 

        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <!-- <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-javadoc-plugin</artifactId> 
      <configuration> 
       <skip>true</skip> 
      </configuration> 
     </plugin> --> 

    </plugins> 
</build> 

任何幫助將非常感激的構建段。

回答

3

APK已壓縮。通過單獨壓縮您的資源,您所做的所有事情都不會在APK壓縮階段完成。

想想這樣,創建一個大的文本文件,將其壓縮成一個zip文件,你會看到zip更小。

現在將此壓縮文本文件壓縮到另一個zip文件中。你期望這個更小嗎?不,它幾乎不會改變,如果有的話更大。

在高層次上,它與壓縮資源基本相同,然後要求APK再次壓縮所有資源。