如何解决库冲突(阿帕奇commons- codeC) [英] How to resolve a library conflict (apache commons-codec)
问题描述
我已经与Android库的问题。
I have a problem with Android libraries.
我想从图书馆org.apache.commons使用的方法Hex.en codeHexString(字节数组)。codec.binary.Hex(版本1.6)
I would like use the method Hex.encodeHexString(Byte Array) from the library org.apache.commons.codec.binary.Hex (version 1.6)
在我的Android平台(SDK 2.3.1),该commons- codeC库版本1.3已经存在,但不会在这个版本(仅连接$ C $环己烷()),但存在的方式。
On my Android platform (SDK 2.3.1), the commons-codec library version 1.3 already exist but the method doesn't exist yet in this version (only encodeHex() ).
我添加了1.6版本的jar库到我的Eclipse项目(进/ libs目录),但是当我运行模拟器项目,我得到这样的:
I added the jar library of version 1.6 into my Eclipse project (into /libs directory) but when I run the project on Emulator, I get this :
E/AndroidRuntime(1632): FATAL EXCEPTION: main
E/AndroidRuntime(1632): java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHexString
我怎么能指示OS哪里是好的图书馆?
How can I indicate the OS where is the good library?
我在Mac OS X使用Eclipse的Juno与Java 1.6.0
I'm using Eclipse Juno with Java 1.6.0 on Mac OS X
对不起,提前我的英语不好,并感谢!
Sorry for my bad english and thanks in advance!
编辑:我的问题可以得到明显解决了jarjar工具。 <一href="http://$c$c.google.com/p/google-http-java-client/issues/detail?id=75">http://$c$c.google.com/p/google-http-java-client/issues/detail?id=75
EDIT : My problem could be apparently solved with jarjar tool. http://code.google.com/p/google-http-java-client/issues/detail?id=75
有人可以帮助我解决这个工具吗?我不知道如何创建一个Ant清单或JAR文件。
Someone could help me with this tool? I don't know how to create an Ant Manifest or a jar file.
感谢
推荐答案
晚答复,但也许有用的人。
Late reply but maybe usefull for someone.
使用 Maven的阴影插件解决的问题
该插件允许在编译重命名冲突库的包名。
This plugin allows to rename package names of conflicted library at compilation.
用法:
<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>
这篇关于如何解决库冲突(阿帕奇commons- codeC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!