首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Jain库创建SipStack时,Android会产生错误。

使用Jain库创建SipStack时,Android会产生错误。
EN

Stack Overflow用户
提问于 2019-07-23 11:07:13
回答 1查看 328关注 0票数 0

在android中,我的代码一到达下一行就会失败。

代码语言:javascript
运行
复制
sipStack = sipFactory.createSipStack(properties);

它给了我以下错误。

代码语言:javascript
运行
复制
W/System.err: android.javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
...
Caused by: java.lang.NoSuchMethodException: gov.nist.javax.sip.SipStackImpl.<init> [class java.util.Properties]

你知道是什么导致了这个错误吗?

我对Jain使用了下面的依赖项。

代码语言:javascript
运行
复制
compile group: 'javax.sip', name: 'android-jain-sip-ri', version: '1.3.0-91'

代码在IntelliJ中运行没有问题。我使用Android和Ubuntu18.04.2LTS。

我的MainActivity类如下所示。

代码语言:javascript
运行
复制
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        new Shootist().init();
    }
}

我的肖奥蒂斯特课程如下。

代码语言:javascript
运行
复制
public class Shootist implements SipListener {

    public void init() {
        SipFactory sipFactory = SipFactory.getInstance();
        sipFactory.setPathName("gov.nist");
        SipStack sipStack = null;

        String transport = "udp";
        String peerHostPort = "127.0.01:5070";

        Properties properties = new Properties();
        properties.setProperty("android.javax.sip.OUTBOUT_PROXY", peerHostPort + "/" + transport);
        properties.setProperty("android.javax.sip.STACK_NAME", "shootist");
        properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "shootistdebug.txt");
        properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "DEBUG");

        System.out.println("trying to create sip stack");
        // create sip stack
        try {
            sipStack = sipFactory.createSipStack(properties);
            System.out.println("sip stack created");

        } catch (PeerUnavailableException e) {
            e.printStackTrace();
        }



    }

    @Override
    public void processRequest(RequestEvent requestEvent) {

    }

    @Override
    public void processResponse(ResponseEvent responseEvent) {

    }

    @Override
    public void processTimeout(TimeoutEvent timeoutEvent) {

    }

    @Override
    public void processIOException(IOExceptionEvent exceptionEvent) {

    }

    @Override
    public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) {

    }

    @Override
    public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) {

    }
}

整个错误输出如下。

代码语言:javascript
运行
复制
07/23 13:55:28: Launching app
D/EGL_emulation: eglMakeCurrent: 0xe431a180: ver 2 0 (tinfo 0xe430f220)
I/System.out: trying to create sip stack
W/testapplicatio: Accessing hidden method Lgov/nist/javax/sip/SipStackImpl;-><init>(Ljava/util/Properties;)V (blacklist, reflection, denied)
W/System.err: android.javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
        at android.javax.sip.SipFactory.createStack(SipFactory.java:324)
        at android.javax.sip.SipFactory.createSipStack(SipFactory.java:152)
        at com.example.jainsiptestapplication.Shootist$override.init(Shootist.java:35)
        at com.example.jainsiptestapplication.Shootist$override.access$dispatch(Unknown Source:107)
        at com.example.jainsiptestapplication.Shootist.init(Unknown Source:12)
        at com.example.jainsiptestapplication.MainActivity.onCreate(MainActivity.java:13)
        at android.app.Activity.performCreate(Activity.java:7783)
        at android.app.Activity.performCreate(Activity.java:7772)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3235)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3396)
        at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5264)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5172)
        at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:57)
        at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:5223)
        at android.app.ActivityThread.access$3400(ActivityThread.java:220)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2019)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7319)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
    Caused by: java.lang.NoSuchMethodException: gov.nist.javax.sip.SipStackImpl.<init> [class java.util.Properties]
        at java.lang.Class.getConstructor0(Class.java:2332)
        at java.lang.Class.getConstructor(Class.java:1728)
        at android.javax.sip.SipFactory.createStack(SipFactory.java:305)
        ... 25 more
Hot swapped changes, activity restarted
D/OpenGLRenderer: Setting buffer count to 3, min_undequeued 1, extraBuffers 0
D/EGL_emulation: eglMakeCurrent: 0xe431a180: ver 2 0 (tinfo 0xe430f220)
D/OpenGLRenderer: Setting buffer count to 3, min_undequeued 1, extraBuffers 0
D/EGL_emulation: eglMakeCurrent: 0xe431a180: ver 2 0 (tinfo 0xe430f220)
I/chatty: uid=10154(com.example.jainsiptestapplication) RenderThread identical 1 line
D/EGL_emulation: eglMakeCurrent: 0xe431a180: ver 2 0 (tinfo 0xe430f220)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-23 11:29:29

主要问题是

代码语言:javascript
运行
复制
sipFactory.setPathName("gov.nist");

应该是

代码语言:javascript
运行
复制
sipFactory.setPathName("android.gov.nist");

初始化与android略有不同。也许您可以从这个示例https://github.com/usnistgov/jsip/tree/master/src/examples/android/simplecallsetup开始,并在其之上构建。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57162777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档