3

我正在尝试在 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参数添加到编译器,如果可以,我该怎么做,我可以在程序中添加命令行选项,但不知道怎么做编译器。另外,这是建议的,还是有其他方法解决这个问题?

4

2 回答 2

3

JAIN jar 正在javax为其包使用命名空间。Android 不允许在外部 jar 中使用核心库。所以你已经重新包装了它们。您可以通过完成以下步骤与AntJarJar结合使用(如错误输出中所述):

在 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你的命令行工具。将新 jars 添加到您的构建路径并删除旧 jars。

于 2012-11-16T15:12:33.847 回答
0

编写了大部分原始 JAIN SIP 堆栈的团队现在支持 JAIN SIP 的 Android 端口:

http://www.telestax.com/jain-sip-stack-for-android/

于 2014-10-08T00:56:48.950 回答