我试图在android上实现jain sip堆栈,但是当我试图编译演示程序时,我得到了以下错误:
trouble processing "javax/sip/ClientTransaction.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
[2012-11-11 22:27:28 - Jain-Test-and] Dx 1 error; aborting
[2012-11-11 22:27:28 - Jain-Test-and] Conversion to Dalvik format failed with error 1
是否可以在eclipse中将--core library参数添加到编译器中,如果可以,如何执行此操作,可以向程序添加命令行选项,但无法确定如何将其添加到编译器中。另外,这是建议的,还是有其他办法?
最佳答案
jain jar正在为其包使用javax
命名空间。android不允许在外部jar中使用核心库。所以你已经重新包装了。您可以结合Ant和JarJar(如错误输出中所述)完成以下步骤:
Install Ant
Follow this tutorial
在build.xml中添加此代码以重新打包jain jars:
<target name="-jarjar" depends="compile">
<taskdef
name="jarjar"
classname="com.tonicsystems.jarjar.JarJarTask"
classpath="buildtools/jarjar-1.4.jar"/>
<jarjar jarfile="${out.absolute.dir}/jain-sip-sdp-repackaged.jar">
<fileset dir="${out.classes.absolute.dir}" />
<zipfileset src="libs/jain-sip-sdp-1.2.2014.jar" />
<rule pattern="javax.**" result="com.demo.@1"/>
<rule pattern="gov.nist.javax.**" result="com.demo.@1"/>
</jarjar>
<jarjar jarfile="${out.absolute.dir}/jain-sip-api-repackaged.jar">
<fileset dir="${out.classes.absolute.dir}" />
<zipfileset src="libs/jain-sip-api-1.2.jar" />
<rule pattern="javax.**" result="com.demo.@1"/>
</jarjar>
<jarjar jarfile="${out.absolute.dir}/jain-sip-ri-repackaged.jar">
<fileset dir="${out.classes.absolute.dir}" />
<zipfileset src="libs/jain-sip-ri-1.2.2014.jar" />
<rule pattern="gov.nist.javax.**" result="com.demo.@1"/>
</jarjar>
</target>
在命令行工具中调用
ant install
。将新jar添加到构建路径并删除旧jar。