Android:我的应用程序不会运行,因为我需要处理一个unknownhostexception。当我这样做崩溃 [英] Android: my application won't run because I need to handle an unknownhostexception. when i do it crashes

查看:1058
本文介绍了Android:我的应用程序不会运行,因为我需要处理一个unknownhostexception。当我这样做崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个需要访问存储在mongodb数据库中的数据的Android应用程序。在我的创建方法中,我继续收到UnknownHostException错误。我已将互联网权限添加到我的清单文件,重新启动我的开发机器,并应用了一个try / catch。现在,应用程序在运行时崩溃(正如打开应用程序)。当我使用我为Android之外的数据库(CrumbsDb)编写的类时,它的工作原理如下。请帮忙。对不起,如果我的问题不够详细,我是新的堆栈溢出和compsci。

Im writing an Android application that needs to access data stored in a mongodb data base. In my on create method I keep on getting an "UnknownHostException" error. I have added the internet permission to my manifest file, restarted my developing machine, and applied a try/catch. Now, the application crashes when I run it (right as the application is opened). When I used the class I wrote for the database (CrumbsDb) outside of android, it works as intended. Please help. Sorry if my question is not detailed enough, I am new to stack overflow and compsci.

    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)


推荐答案

此驱动程序不支持Android ;有一个公开问题,供mongo支持。

This driver does not support Android; there is an open issue for mongo to support it.

这篇关于Android:我的应用程序不会运行,因为我需要处理一个unknownhostexception。当我这样做崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆