我正在尝试打包使用Akka的应用程序,但我收到一条众所周知的错误消息:
[INFO] trouble writing output: Too many method references: 80536; max is 65536.
[INFO] You may try using --multi-dex option.
我发现了一个应该缩小Akka库的proguard配置: https://bitbucket.org/mackler/safe-metronome/src/16f880347863f560d025016ece19d586fbb9874d/project/proguard.cfg?at=default
我将我的Maven构建设置为使用类似的配置,但似乎这个Akka库没有缩小。据我所知,在项目依赖项上应用proguard时,有必要制作一个包含所有依赖项的jar,然后将它加入jar到proguard。
这是我的Maven配置:
<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>
我做错了什么?
P.S。 dex工具建议使用&#39; - multi-dex&#39;选项,但我没有找到如何使用Maven android插件添加它。有没有解决方法?
答案 0 :(得分:0)
毕竟这是有效的配置:
<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>
答案 1 :(得分:0)
回答一个略微修改过的问题“使用SBT与Proguard一起收缩Akka”
将使用Proguard SBT插件。 GitHub上的Here's an example of shrinking Akka with it.。