2012-01-10 52 views
0

我正在写一个Android应用程序,需要访问存储在mongodb数据库中的数据。在我的创建方法中,我一直在获取“UnknownHostException”错误。我已经将Internet权限添加到清单文件中,重新启动了我的开发机器,并应用了try/catch。现在,当我运行应用程序时,应用程序崩溃(正如应用程序打开时一样)。当我使用我为Android之外的数据库(CrumbsDb)编写的类时,它按预期工作。请帮忙。对不起,如果我的问题不够详细,我是堆栈溢出和compsci的新手。Android:我的应用程序不会运行,因为我需要处理一个unknownhostexception。当我这样做崩溃

String name = "Crumb Not Available"; 
    try { 
     CrumbsDb db = new CrumbsDb(); 
     name = db.getName("Chipotle"); 
    } catch (UnknownHostException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    TextView crumbName = (TextView) findViewById(R.id.crumb_name); 
    crumbName.setText(name); 

以下是错误日志

01-10 13:42:37.223: I/dalvikvm(506): Could not find method java.lang.management.ManagementFactory.getRuntimeMXBean, referenced from method org.bson.types.ObjectId.<clinit> 
01-10 13:42:37.223: W/dalvikvm(506): VFY: unable to resolve static method 1544: Ljava/lang/management/ManagementFactory;.getRuntimeMXBean()Ljava/lang/management/RuntimeMXBean; 
01-10 13:42:37.273: D/dalvikvm(506): VFY: replacing opcode 0x71 at 0x0071 
01-10 13:42:37.273: D/dalvikvm(506): VFY: dead code 0x0074-007c in Lorg/bson/types/ObjectId;.<clinit>()V 
01-10 13:42:37.373: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.373: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.373: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.373: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.373: W/dalvikvm(506): VFY: unable to find class referenced in signature (Lcom/mongodb/DBPortPool;) 
01-10 13:42:37.373: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.383: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.383: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.383: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.383: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.383: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.383: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.383: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.393: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.393: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.393: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.393: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.393: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.403: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.403: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.403: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.403: I/dalvikvm(506): Could not find method com.mongodb.DBPortPool.getServerAddress, referenced from method com.mongodb.DBTCPConnector._set 
01-10 13:42:37.403: W/dalvikvm(506): VFY: unable to resolve virtual method 441: Lcom/mongodb/DBPortPool;.getServerAddress()Lcom/mongodb/ServerAddress; 
01-10 13:42:37.403: D/dalvikvm(506): VFY: replacing opcode 0x6e at 0x002b 
01-10 13:42:37.403: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.403: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.403: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.413: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.413: D/dalvikvm(506): VFY: dead code 0x002e-0043 in Lcom/mongodb/DBTCPConnector;._set (Lcom/mongodb/ServerAddress;)Z 
01-10 13:42:37.413: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.413: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.413: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.413: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.423: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.423: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.423: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.423: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.423: W/dalvikvm(506): VFY: unable to find class referenced in signature (Lcom/mongodb/DBPortPool;) 
01-10 13:42:37.443: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.443: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.443: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.443: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.454: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.454: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.454: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.454: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.454: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.454: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.454: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.454: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.463: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.463: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.473: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.473: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.473: I/dalvikvm(506): Could not find method com.mongodb.DBPortPool.get, referenced from method com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize 
01-10 13:42:37.473: W/dalvikvm(506): VFY: unable to resolve virtual method 438: Lcom/mongodb/DBPortPool;.get()Lcom/mongodb/DBPort; 
01-10 13:42:37.473: D/dalvikvm(506): VFY: replacing opcode 0x6e at 0x0008 
01-10 13:42:37.473: D/dalvikvm(506): VFY: dead code 0x000b-0076 in Lcom/mongodb/DBTCPConnector;.fetchMaxBsonObjectSize()I 
01-10 13:42:37.473: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.473: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.473: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.483: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.483: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.483: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.483: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.483: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.493: I/dalvikvm(506): Could not find method com.mongodb.DBPortPool.getServerAddress, referenced from method com.mongodb.DBTCPConnector.getAddress 
01-10 13:42:37.493: W/dalvikvm(506): VFY: unable to resolve virtual method 441: Lcom/mongodb/DBPortPool;.getServerAddress()Lcom/mongodb/ServerAddress; 
01-10 13:42:37.493: D/dalvikvm(506): VFY: replacing opcode 0x6e at 0x0004 
01-10 13:42:37.493: D/dalvikvm(506): VFY: dead code 0x0007-0007 in Lcom/mongodb/DBTCPConnector;.getAddress()Lcom/mongodb/ServerAddress; 
01-10 13:42:37.493: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.493: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.493: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.503: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.503: W/dalvikvm(506): VFY: unable to find class referenced in signature (Lcom/mongodb/DBPortPool;) 
01-10 13:42:37.503: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.503: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.503: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.503: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.503: W/dalvikvm(506): VFY: unable to find class referenced in signature (Lcom/mongodb/DBPortPool;) 
01-10 13:42:37.513: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.513: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.513: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.513: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.513: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.513: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.523: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.523: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.523: I/dalvikvm(506): Could not find method com.mongodb.DBPortPool.get, referenced from method com.mongodb.DBTCPConnector.testMaster 
01-10 13:42:37.523: W/dalvikvm(506): VFY: unable to resolve virtual method 438: Lcom/mongodb/DBPortPool;.get()Lcom/mongodb/DBPort; 
01-10 13:42:37.523: D/dalvikvm(506): VFY: replacing opcode 0x6e at 0x0003 
01-10 13:42:37.523: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.523: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.523: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.523: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.533: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.533: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.533: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.533: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.533: I/dalvikvm(506): Could not find method com.mongodb.DBPortPool.done, referenced from method com.mongodb.DBTCPConnector.testMaster 
01-10 13:42:37.533: W/dalvikvm(506): VFY: unable to resolve virtual method 437: Lcom/mongodb/DBPortPool;.done (Ljava/lang/Object;)V 
01-10 13:42:37.533: D/dalvikvm(506): VFY: replacing opcode 0x6e at 0x0032 
01-10 13:42:37.533: D/dalvikvm(506): VFY: dead code 0x0006-0023 in Lcom/mongodb/DBTCPConnector;.testMaster()V 
01-10 13:42:37.533: D/dalvikvm(506): VFY: dead code 0x0035-0035 in Lcom/mongodb/DBTCPConnector;.testMaster()V 
01-10 13:42:37.543: I/dalvikvm(506): Could not find method java.lang.management.ManagementFactory.getPlatformMBeanServer, referenced from method com.mongodb.DBPortPool$Holder.<init> 
01-10 13:42:37.543: W/dalvikvm(506): VFY: unable to resolve static method 1543: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer()Ljavax/management/MBeanServer; 
01-10 13:42:37.543: D/dalvikvm(506): VFY: replacing opcode 0x71 at 0x0011 
01-10 13:42:37.543: D/dalvikvm(506): VFY: dead code 0x0014-0014 in Lcom/mongodb/DBPortPool$Holder;.<init> (Lcom/mongodb/MongoOptions;)V 
01-10 13:42:37.553: E/dalvikvm(506): Could not find class 'javax.management.ObjectName', referenced from method com.mongodb.DBPortPool$Holder.createObjectName 
01-10 13:42:37.553: W/dalvikvm(506): VFY: unable to resolve new-instance 305 (Ljavax/management/ObjectName;) in Lcom/mongodb/DBPortPool$Holder; 
01-10 13:42:37.553: D/dalvikvm(506): VFY: replacing opcode 0x22 at 0x004e 
01-10 13:42:37.553: D/dalvikvm(506): VFY: dead code 0x0050-0053 in Lcom/mongodb/DBPortPool$Holder;.createObjectName (Lcom/mongodb/ServerAddress;)Ljavax/management/ObjectName; 
01-10 13:42:37.553: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.553: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.553: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.553: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.553: E/dalvikvm(506): Could not find class 'com.mongodb.DBPortPool', referenced from method com.mongodb.DBPortPool$Holder.close 
01-10 13:42:37.553: W/dalvikvm(506): VFY: unable to resolve check-cast 56 (Lcom/mongodb/DBPortPool;) in Lcom/mongodb/DBPortPool$Holder; 
01-10 13:42:37.553: D/dalvikvm(506): VFY: replacing opcode 0x1f at 0x0017 
01-10 13:42:37.563: D/dalvikvm(506): VFY: dead code 0x0019-003a in Lcom/mongodb/DBPortPool$Holder;.close()V 
01-10 13:42:37.563: I/dalvikvm(506): Failed resolving Lcom/mongodb/util/SimplePool; interface 298 'Ljavax/management/DynamicMBean;' 
01-10 13:42:37.563: W/dalvikvm(506): Link of class 'Lcom/mongodb/util/SimplePool;' failed 
01-10 13:42:37.563: W/dalvikvm(506): Unable to resolve superclass of Lcom/mongodb/DBPortPool; (146) 
01-10 13:42:37.563: W/dalvikvm(506): Link of class 'Lcom/mongodb/DBPortPool;' failed 
01-10 13:42:37.563: E/dalvikvm(506): Could not find class 'com.mongodb.DBPortPool', referenced from method com.mongodb.DBPortPool$Holder.get 
01-10 13:42:37.563: W/dalvikvm(506): VFY: unable to resolve check-cast 56 (Lcom/mongodb/DBPortPool;) in Lcom/mongodb/DBPortPool$Holder; 
01-10 13:42:37.573: D/dalvikvm(506): VFY: replacing opcode 0x1f at 0x0006 
01-10 13:42:37.573: D/dalvikvm(506): VFY: dead code 0x0008-0099 in Lcom/mongodb/DBPortPool$Holder;.get (Lcom/mongodb/ServerAddress;)Lcom/mongodb/DBPortPool; 
01-10 13:42:37.573: D/AndroidRuntime(506): Shutting down VM 
01-10 13:42:37.573: W/dalvikvm(506): threadid=1: thread exiting with uncaught exception (group=0x40015560) 
01-10 13:42:37.593: E/AndroidRuntime(506): FATAL EXCEPTION: main 
01-10 13:42:37.593: E/AndroidRuntime(506): java.lang.NoClassDefFoundError: com.mongodb.DBPortPool 
01-10 13:42:37.593: E/AndroidRuntime(506): at com.mongodb.DBPortPool$Holder.get(DBPortPool.java:57) 
01-10 13:42:37.593: E/AndroidRuntime(506): at com.mongodb.DBTCPConnector._set(DBTCPConnector.java:488) 
01-10 13:42:37.593: E/AndroidRuntime(506): at com.mongodb.DBTCPConnector.<init>(DBTCPConnector.java:44) 
01-10 13:42:37.593: E/AndroidRuntime(506): at com.mongodb.Mongo.<init>(Mongo.java:272) 
01-10 13:42:37.593: E/AndroidRuntime(506): at breadcrumbs.java.CrumbsDb.<init>(CrumbsDb.java:21) 
01-10 13:42:37.593: E/AndroidRuntime(506): at breadcrumbs.java.BreadCrumbsActivity.onCreate(BreadCrumbsActivity.java:28) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.os.Handler.dispatchMessage(Handler.java:99) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.os.Looper.loop(Looper.java:123) 
01-10 13:42:37.593: E/AndroidRuntime(506): at android.app.ActivityThread.main(ActivityThread.java:3683) 
01-10 13:42:37.593: E/AndroidRuntime(506): at java.lang.reflect.Method.invokeNative(Native Method) 
01-10 13:42:37.593: E/AndroidRuntime(506): at java.lang.reflect.Method.invoke(Method.java:507) 
01-10 13:42:37.593: E/AndroidRuntime(506): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
01-10 13:42:37.593: E/AndroidRuntime(506): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
01-10 13:42:37.593: E/AndroidRuntime(506): at dalvik.system.NativeStart.main(Native Method) 
+1

我不确定你可以在Android应用程序中使用mongoDB数据库,你得到的栈跟踪是什么? – 2012-01-10 18:32:11

+0

你确定你在应用程序mongoDB系统的主机名/ IP是否正确?你是否从你的开发机器ping mongoDB机器? – kosa 2012-01-10 18:47:32

+0

是的,我确定。我在文本编辑中使用纯java文件测试了主机名/ ip,并运行它来打印出结果;它按照预期工作。尽管我现在刚刚发现并收到了100%的数据包丢失(主机是32位Amazon EC2 Linux机箱)。 – 2012-01-10 19:38:52

回答

相关问题