我正在尝试打包使用 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 build设置为使用类似的配置,但这个 Akka 库似乎并没有缩小。据我了解,要在项目依赖项上应用混淆器,有必要制作一个包含所有依赖项的单个 jar,然后将其加入的 jar 提供给混淆器。
这是我的 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>
我做错了什么?
附注dex 工具建议使用“--multi-dex”选项,但我没有找到如何使用 Maven android 插件添加它。有什么解决办法吗?
最佳答案
这是最终有效的配置:
<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>
关于java - 使用 Maven 通过 Proguard 缩小 Akka,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23358957/