不幸的是,<appname>已停止工作</appname>

时间:2014-06-04 07:31:25

标签: java android

我是Android新手。当我在AVD上运行该应用时,它会显示“Unfortunately <Application name> has stopped”。这是我下面的logcat。有人可以检查并帮助我吗?

06-04 12:48:31.492: E/Trace(635): error opening trace file: No such file or directory (2)
06-04 12:48:32.192: I/MapLocation(635): The activity is about to become visible.
06-04 12:48:32.192: I/MapLocation(635): The activity has become visible (it is now "resumed")
06-04 12:48:32.422: D/gralloc_goldfish(635): Emulator without GPU emulation detected.
06-04 12:48:35.142: I/MapLocation(635): Another activity is taking focus (this activity is about to be "paused")
06-04 12:48:36.772: I/MapLocation(635): The activity is no longer visible (it is now "stopped")
06-04 12:48:41.412: D/AndroidRuntime(635): Shutting down VM
06-04 12:48:41.412: W/dalvikvm(635): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
06-04 12:48:41.453: E/AndroidRuntime(635): FATAL EXCEPTION: main
06-04 12:48:41.453: E/AndroidRuntime(635): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { dat=content://com.android.contacts/contacts/lookup/0r2-272D273F4543494D2F49/2 flg=0x1 }} to activity {com.example.maplocationcontacts/com.example.maplocationcontacts.MainActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=635, uid=10045 requires android.permission.READ_CONTACTS, or grantUriPermission()
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.app.ActivityThread.deliverResults(ActivityThread.java:3141)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.app.ActivityThread.handleSendResult(ActivityThread.java:3184)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.app.ActivityThread.access$1100(ActivityThread.java:130)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.os.Looper.loop(Looper.java:137)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.app.ActivityThread.main(ActivityThread.java:4745)
06-04 12:48:41.453: E/AndroidRuntime(635):  at java.lang.reflect.Method.invokeNative(Native Method)
06-04 12:48:41.453: E/AndroidRuntime(635):  at java.lang.reflect.Method.invoke(Method.java:511)
06-04 12:48:41.453: E/AndroidRuntime(635):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-04 12:48:41.453: E/AndroidRuntime(635):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-04 12:48:41.453: E/AndroidRuntime(635):  at dalvik.system.NativeStart.main(Native Method)
06-04 12:48:41.453: E/AndroidRuntime(635): Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=635, uid=10045 requires android.permission.READ_CONTACTS, or grantUriPermission()
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.os.Parcel.readException(Parcel.java:1425)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.content.ContentResolver.query(ContentResolver.java:370)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.content.ContentResolver.query(ContentResolver.java:313)
06-04 12:48:41.453: E/AndroidRuntime(635):  at com.example.maplocationcontacts.MainActivity.onActivityResult(MainActivity.java:67)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.app.Activity.dispatchActivityResult(Activity.java:5192)
06-04 12:48:41.453: E/AndroidRuntime(635):  at android.app.ActivityThread.deliverResults(ActivityThread.java:3137)
06-04 12:48:41.453: E/AndroidRuntime(635):  ... 11 more
06-04 12:48:50.692: I/Process(635): Sending signal. PID: 635 SIG: 9

1 个答案:

答案 0 :(得分:1)

这一行解释了它:

06-04 12:48:41.453: E/AndroidRuntime(635): Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=635, uid=10045 requires android.permission.READ_CONTACTS, or grantUriPermission()

您的应用程序可能会访问“联系人”信息,因此您必须在“清单”(<manifest>)中声明它:

<uses-permission android:name="android.permission.READ_CONTACTS" />