qq_38034939
2017-08-02 11:38
采纳率: 46.2%
浏览 4.5k

android大神过来看看我的错误,刚学android不会看

08-02 19:31:44.213 32733-474/com.example.lenovo.push E/AndroidRuntime: FATAL EXCEPTION: ModernAsyncTask #1
Process: com.example.lenovo.push, PID: 32733
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:161)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=32733, uid=10358 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1693)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:536)
at android.support.v4.content.ContentResolverCompatJellybean.query(ContentResolverCompatJellybean.java:33)
at android.support.v4.content.ContentResolverCompat$ContentResolverCompatImplJB.query(ContentResolverCompat.java:57)
at android.support.v4.content.ContentResolverCompat.query(ContentResolverCompat.java:125)
at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:59)
at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:37)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:302)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:57)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:45)
at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:138)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:762) 

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

8条回答 默认 最新

  • legendCoder 2017-08-03 01:23
    已采纳

    那就看一下你的sdk版本了,在6.0(api 23)以上的版本里面有的权限不仅需要在配置文件中配置,还需要在运行时动态申请权限。参考一下:http://blog.csdn.net/likesidehu/article/details/52668879

    点赞 评论
  • legendCoder 2017-08-02 13:50

    很明确啊,缺少android.permission.READ_EXTERNAL_STORAGE权限。在配置文件加入扩展内存读取权限即可。

    点赞 评论
  • qq_38034939 2017-08-02 15:11

    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

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

    加了

    点赞 评论
  • WL-鬼 2017-08-03 01:45

    看 : Caused by 后面明显提示 需要权限 android.permission.READ_EXTERNAL_STORAGE
    在清单文件中去添加即可

    点赞 评论
  • 丶寿司 2017-08-03 01:49

    sdk版本如果是api23以上,还需要在运行时动态申请权限。

    点赞 评论
  • huohao-nicole 2017-08-03 03:52

    从错误日志上看就是Android 6.0运行时权限问题

    点赞 评论
  • whyMyHelloWorld 2017-08-03 06:45
    点赞 评论
  • Code_legend 2017-08-05 04:40

    如果楼主嫌弃动态申请权限麻烦的话可以把 这样设置 targetSdkVersion 21

    点赞 评论

相关推荐 更多相似问题