我正在尝试在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参数添加到编译器中,如果是这样,我该怎么做,我可以为程序添加命令行选项,但是无法弄清楚如何做它到编译器。此外,这是建议,还是有另一种解决方法?
答案 0 :(得分:3)
JAIN jar正在使用javax
命名空间作为其包。 Android不允许在外部jar中使用核心库。所以你要重新包装它们。您可以结合Ant和JarJar(如错误输出中所述)执行此操作,完成以下步骤:
在build.xml中添加此代码以重新打包JAIN jar:
<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。
答案 1 :(得分:0)
现在,由编写了大量原始JAIN SIP堆栈的团队支持JAIN SIP的Android端口: