希望我的问题不是太傻,但我遇到了以下问题……
我正在将包含库JmDNS的jar导入到我的项目中.我的项目设置为像这样处理JmDNS ……
setUp();
try {
peer = new PublicPeer("Aidan",6666,6667,this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
private void setUp(){
android.net.wifi.WifiManager wifi =
(android.net.wifi.WifiManager)
getSystemService(android.content.Context.WIFI_SERVICE);
lock = wifi.createMulticastLock("Lock");
lock.setReferenceCounted(true);
lock.acquire();
}
其中lock = android.net.wifi.WifiManager.MulticastLock lock;和PublicPeer同行;
执行到达peer = new PublicPeer(“Aidan”,6666,6667,this);以下错误输出……
11-13 13:12:47.644: W/dalvikvm(204): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
11-13 13:12:47.644: E/AndroidRuntime(204): Uncaught handler: thread main exiting due to uncaught exception
11-13 13:12:47.664: E/AndroidRuntime(204): java.lang.NoClassDefFoundError: javax.jmdns.JmDNS
11-13 13:12:47.664: E/AndroidRuntime(204): at com.daniel.business.publicchat.PeerAdvertiser.(PeerAdvertiser.java:36)
11-13 13:12:47.664: E/AndroidRuntime(204): at com.daniel.business.publicchat.PublicPeer.(PublicPeer.java:60)
11-13 13:12:47.664: E/AndroidRuntime(204): at com.chatr.org.PublicChat.onCreate(PublicChat.java:21)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.os.Looper.loop(Looper.java:123)
11-13 13:12:47.664: E/AndroidRuntime(204): at android.app.ActivityThread.main(ActivityThread.java:4363)
11-13 13:12:47.664: E/AndroidRuntime(204): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 13:12:47.664: E/AndroidRuntime(204): at java.lang.reflect.Method.invoke(Method.java:521)
11-13 13:12:47.664: E/AndroidRuntime(204): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-13 13:12:47.664: E/AndroidRuntime(204): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-13 13:12:47.664: E/AndroidRuntime(204): at dalvik.system.NativeStart.main(Native Method)
如果我对上述内容的理解是正确的,那么我的JmDNS库就会出现问题,但它正在被添加.我百分百肯定.我导入的JAR代码可以在这里找到:https://github.com/Ps2Fino/DSProject-Backend
编辑
JmDNS被添加到Android中似乎是一个问题,如此处所述:http://home.heeere.com/tech-androidjmdns.html我试图按照该指南“重新评估”JmDNS JAR文件,但我仍然遇到同样的问题.它看起来效果不佳.