Aiden Fry
Aiden Fry

Reputation: 1682

Android Compressing resources makes NO change in APK size

We are working on size optimisation for my Android Application.

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.

Can someone explain why this is happening?

I am zipaligning but thats all in the pom.

here is the build segment of the 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.

Upvotes: 0

Views: 568

Answers (1)

Richard Taylor
Richard Taylor

Reputation: 2742

An APK is already compressed. By compressing your resources individually, all your doing is leaving less to be done in the APK compression stage.

Think of it this way, create a large text file, compress it into a zip, and you'll see the zip is far smaller.

Now compress this zipped text file, into another zip file. 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.

Upvotes: 3

Related Questions