简体   繁体   English

Android压缩资源不会改变APK大小

[英]Android Compressing resources makes NO change in APK size

We are working on size optimisation for my Android Application. 我们正在为我的Android应用程序进行尺寸优化。

However after we have made significant reductions in the size of the resources folder, reduced it by 8mb, when i compile (using maven) the size of the app is only reduced by .1 mb. 但是,在我们大幅减少资源文件夹的大小之后,将其减少了8mb,而当我编译(使用maven)时,应用程序的大小仅减少了0.1 mb。

Can someone explain why this is happening? 有人可以解释为什么会这样吗?

I am zipaligning but thats all in the pom. 我正在拉链对齐,但多数民众赞成在pom中。

here is the build segment of the pom 这是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>

Any help will be much appreciated. 任何帮助都感激不尽。

An APK is already compressed. APK已被压缩。 By compressing your resources individually, all your doing is leaving less to be done in the APK compression stage. 通过单独压缩资源,您要做的只是在APK压缩阶段减少工作量。

Think of it this way, create a large text file, compress it into a zip, and you'll see the zip is far smaller. 以这种方式思考,创建一个大文本文件,将其压缩为一个zip文件,您会发现zip文件要小得多。

Now compress this zipped text file, into another zip file. 现在,将此压缩的文本文件压缩为另一个zip文件。 Do you expect that to be any smaller? 您希望它会更小吗? Nope, it'll barely change, larger if anything. 不,它几乎不会改变,更大的话。

On a high level, it's basically the same as compressing your resources, then asking the APK to compress all of them again. 从高层次上讲,它基本上与压缩资源相同,然后要求APK重新压缩所有资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM