nbe*_*_42 7 apache android conflict nosuchmethoderror apache-commons-codec
我的Android库有问题.
我想使用库org.apache.commons.codec.binary.Hex(版本1.6)中的Hex.encodeHexString(字节数组)方法
在我的Android平台(SDK 2.3.1)上,commons-codec库版本1.3已经存在但该方法在此版本中尚不存在(只有encodeHex()).
我将版本1.6的jar库添加到我的Eclipse项目中(到/ libs目录中)但是当我在Emulator上运行项目时,我得到了这个:
E/AndroidRuntime(1632): FATAL EXCEPTION: main
E/AndroidRuntime(1632): java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHexString
Run Code Online (Sandbox Code Playgroud)
我如何指出操作系统在哪里是好的库?
我在Mac OS X上使用Eclipse Juno和Java 1.6.0
抱歉我的英文不好,并提前致谢!
编辑:我的问题可以用jarjar工具显然解决. http://code.google.com/p/google-http-java-client/issues/detail?id=75
有人可以帮我使用这个工具吗?我不知道如何创建Ant Manifest或jar文件.
谢谢
nbe*_*_42 10
迟到的回复,但也许对某人有用.
使用Maven Shade插件解决了问题
此插件允许在编译时重命名冲突库的包名称.
用法:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>com.example.shaded.org.apache.commons</shadedPattern>
</relocation>
</relocations>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8182 次 |
最近记录: |