Android - 权限拒绝(scanLibrary ?!)

时间:2016-09-09 07:50:06

标签: android android-manifest securityexception

我正在尝试开发一个扫描文档的简单应用程序。我正在使用由jhansireddy(https://github.com/jhansireddy/AndroidScannerDemo)提供的scanlibrary。我已经将库与我的实际项目集成在一起,我完成了gradle构建。

当我开始活动时,我可以选择从图库中选择一张照片,或者选择一张全新的照片。在这两种情况下,它都会在内存中保存时崩溃(需要android.permission.WRITE_EXTERNAL_STORAGE)。

下面我将从logcat粘贴整个错误。

09-09 10:40:51.219 27738-27738/com.example.cosmin.kdocscanner E/MediaStore: Failed to insert image
java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=27738, uid=10158 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()
    at android.os.Parcel.readException(Parcel.java:1599)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
    at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
    at android.content.ContentResolver.insert(ContentResolver.java:1251)
    at android.provider.MediaStore$Images$Media.insertImage(MediaStore.java:971)
    at com.scanlibrary.Utils.getUri(Utils.java:23)
    at com.scanlibrary.PickImageFragment.postImagePick(PickImageFragment.java:146)
    at com.scanlibrary.PickImageFragment.onActivityResult(PickImageFragment.java:141)
    at android.app.Activity.dispatchActivityResult(Activity.java:6487)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3738)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3785)
    at android.app.ActivityThread.access$1400(ActivityThread.java:157)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5525)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

在这之后,我认为另一个是副作用。这意味着,在我解决第一个问题时,它将解决另一个问题。

09-09 10:40:51.220 27738-27738/com.example.cosmin.kdocscanner E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.cosmin.kdocscanner, PID: 27738
java.lang.RuntimeException: Failure delivering result ResultInfo{who=android:fragment:0, request=2, result=-1, data=null} to activity {com.example.cosmin.kdocscanner/com.scanlibrary.ScanActivity}: java.lang.NullPointerException: uriString
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3742)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3785)
    at android.app.ActivityThread.access$1400(ActivityThread.java:157)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5525)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
    Caused by: java.lang.NullPointerException: uriString
    at android.net.Uri$StringUri.<init>(Uri.java:475)
    at android.net.Uri$StringUri.<init>(Uri.java:465)
    at android.net.Uri.parse(Uri.java:437)
    at com.scanlibrary.Utils.getUri(Utils.java:24)
    at com.scanlibrary.PickImageFragment.postImagePick(PickImageFragment.java:146)
    at com.scanlibrary.PickImageFragment.onActivityResult(PickImageFragment.java:141)
    at android.app.Activity.dispatchActivityResult(Activity.java:6487)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3738)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3785) 
    at android.app.ActivityThread.access$1400(ActivityThread.java:157) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5525) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

我必须说android manifest已经获得了许可。实际上,两个清单文件(属于我的项目的文件和属于库的文件)。

可能是什么原因?!

0 个答案:

没有答案