Android 在使用 Jain-SIP 库创建 SipStack 时出错
Posted
技术标签:
【中文标题】Android 在使用 Jain-SIP 库创建 SipStack 时出错【英文标题】:Android gives error when creating SipStack using Jain-SIP library 【发布时间】:2019-12-01 10:02:51 【问题描述】:在 android studio 中,我的代码一旦到达以下行就会失败。
sipStack = sipFactory.createSipStack(properties);
它给了我以下错误。
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-SIP 使用以下依赖项。
compile group: 'javax.sip', name: 'android-jain-sip-ri', version: '1.3.0-91'
代码在 IntelliJ 中运行没有问题。 我正在使用带有 Ubuntu 18.04.2 LTS 的 Android Studio。
我的 MainActivity 类如下。
public class MainActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Shootist().init();
我的 Shootist 课程如下。
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)
整个错误输出如下。
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)
【问题讨论】:
【参考方案1】:主要问题是
sipFactory.setPathName("gov.nist");
应该是
sipFactory.setPathName("android.gov.nist");
初始化与android略有不同。也许你可以从这个例子开始 https://github.com/usnistgov/jsip/tree/master/src/examples/android/simplecallsetup 并在它之上构建。
【讨论】:
这实际上是我正在尝试构建的示例。该示例在我运行时似乎不起作用,因此我试图通过从头开始处理它来找出问题所在。哦,谢谢你的回答;解决了这个问题。以上是关于Android 在使用 Jain-SIP 库创建 SipStack 时出错的主要内容,如果未能解决你的问题,请参考以下文章
在没有Android Studio的情况下为Android创建(Cmake)C / C ++库
如何使用 iText 或 android 上的其他库创建 PDF 文件?