简体   繁体   中英

Android gives error when creating SipStack using Jain-SIP library

In android studio, my code fails as soon as it reaches the following line.

sipStack = sipFactory.createSipStack(properties);

It gives me the following error.

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]

Do you know what might be causing this error?


I'm using the following dependency for Jain-SIP.

compile group: 'javax.sip', name: 'android-jain-sip-ri', version: '1.3.0-91'

The code has no problem running in IntelliJ. I'm using Android Studio with Ubuntu 18.04.2 LTS.


My MainActivity class is as follows.

public class MainActivity extends AppCompatActivity {

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

My Shootist class is as follows.

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) {

    }
}

The entire error output is below.

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)

The main issue is

sipFactory.setPathName("gov.nist");

should be

sipFactory.setPathName("android.gov.nist");

Initialisation is slightly different with android. Perhaps you can start with this example https://github.com/usnistgov/jsip/tree/master/src/examples/android/simplecallsetup and built on top of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM