سؤال

I am trying to package application that uses Akka, but I receive a well known error message:

[INFO] trouble writing output: Too many method references: 80536; max is 65536.
[INFO] You may try using --multi-dex option.

I found a proguard configuration that should shrink Akka library: https://bitbucket.org/mackler/safe-metronome/src/16f880347863f560d025016ece19d586fbb9874d/project/proguard.cfg?at=default

I set up my Maven build to use similar configuration, but it does not seem that this Akka library is shrinked. As far as I understand to apply proguard on project dependencies it is necessary to make a single jar with all dependencies and than feed it joined jar to proguard.

Here is my Maven config:

<dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor_2.10</artifactId>
            <version>2.4-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <finalName>${project.artifactId}</finalName>

        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.7.0</version>
                <extensions>true</extensions>
                <configuration>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                </configuration>
            </plugin>

            <plugin>
                  <artifactId>maven-assembly-plugin</artifactId>
                  <configuration>
                      <descriptorRefs>
                          <descriptorRef>jar-with-dependencies</descriptorRef>
                      </descriptorRefs>
                  </configuration>
                  <executions>
                      <execution>
                          <id>make-assembly</id>
                          <phase>package</phase>
                          <goals>
                              <goal>assembly</goal>
                          </goals>
                      </execution>
                  </executions>
              </plugin>
            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.6</version>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>4.9</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                    </libs>
                    <obfuscate>false</obfuscate>
                    <options>
                        <option>@proguard.cfg</option>
                    </options>
                </configuration>
            </plugin>

        </plugins>
    </build>

What am I doing wrong?

P.S. dex tool is suggesting to use '--multi-dex' option, but I didn't find how to add it with Maven android plugin. Is there any workaround?

هل كانت مفيدة؟

المحلول

Here is the configuration that worked after all:

<build>
    <sourceDirectory>src</sourceDirectory>

    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>                 
                <manifest>
                    <debuggable>true</debuggable>
                </manifest>
                <proguard>
                    <config>proguard.cfg</config>
                    <skip>false</skip>
                </proguard>
                <sdk>
                    <platform>16</platform>
                </sdk>
                <test>
                    <skip>true</skip>
                </test>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

نصائح أخرى

Answer to a slightly modified version of the question "Shrink Akka with Proguard using SBT"

Would be to use the Proguard SBT plugin. Here's an example of shrinking Akka with it. on GitHub.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top