调试时未在Android Studio中捕获异常 [英] Exceptions are not being caught in Android Studio when debugging

查看:200
本文介绍了调试时未在Android Studio中捕获异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将在Eclipse上开发的项目导入到Android Studio中.在我的设备上从Eclipse运行\调试该项目时,该项目运行正常.

I have imported a project that was developed on Eclipse into Android Studio. The project is working perfectly when running\debugging it from Eclipse on my device.

从我的设备上的Android Studio调试时,应用程序崩溃,并且在Android Studio上未捕获任何异常.

When debugging from the Android Studio on my device, the application is crashing and no exception is being caught on the Android Studio.

当我放置断点时,它们工作正常,所以我知道我正在调试正确的代码:)

When I place breakpoints, they work fine, so I know i'm debugging the correct code :)

我再次运行它,并在logcat中得到以下异常(调试器不应该在代码中的某个地方停止显示异常吗?就像在尝试访问该文件的行中一样?):

I have run it again and got the following Exception in the logcat (shouldn't the debugger stop somewhere in the code to show the Exception? like in the line that tries to access the file?):

2018-10-24 11:25:26.027 25903-25903/? E/libpersona: Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory
2018-10-24 11:25:31.735 23290-23301/? E/DatabaseUtils: Writing exception to parcel
    java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=25858, uid=10314 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
        at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:639)
        at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:505)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:217)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:102)
        at android.os.Binder.execTransact(Binder.java:682)

尽管我确实在AndroidMenifest.xml中设置了权限:

Although I do have permissions set in the AndroidMenifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.eibimalul.smartgallery"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_SOCIAL_STREAM"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

解决方案:

显然,我错过了两件事:

So apparently I was missing 2 things:

    我使用此链接此处以及@Pier Giorgio Misley的评论的帮助
  1. 我缺少对AndroidManifest.xml的权限:

  1. run-time permissions which I understood using this link here and with the help of @Pier Giorgio Misley's comment
  2. I was missing permissions on the AndroidManifest.xml:

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

推荐答案

解决方案:

显然我错过了两件事:

  1. 使用此链接此处可以理解的运行时权限在@Pier Giorgio Misley的评论的帮助下
  2. 我缺少对AndroidManifest.xml的权限:

  1. Run-time permissions which I understood using this link here and with the help of @Pier Giorgio Misley's comment
  2. I was missing permissions on the AndroidManifest.xml:

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

我不确定这是否是正确的方法(回答我自己的问题),因为我仅在评论中得到了少数开发人员(尤其是@Pier Giorgio Misley)的帮助,但我认为这是正确的重要的是将问题标记为已回答.

I am not sure if that's the right way to do it (answering my own question that is), since I got help from few developers here (@Pier Giorgio Misley in particular) in the comments only, but I thought it is important to mark the question as answered.

这篇关于调试时未在Android Studio中捕获异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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