首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用目标SDK强制关闭

使用目标SDK强制关闭
EN

Stack Overflow用户
提问于 2017-03-12 04:04:09
回答 2查看 125关注 0票数 0

我对这个源(Ringdroid:https://github.com/google/ringdroid )有一个问题,上个月我更新了我的应用程序,目标是安卓23,但我刚刚意识到当我用安卓23,24,25启动我的应用程序时,它让我强制关闭,所以我把目标sdk改成了22,但谷歌play商店说这是可能的,因为之前的版本是针对23的。问题是,它是一个bug吗?我需要我的项目在android 23上的目标,并仍然给我强制关闭时,我使用模拟器或智能手机打开使用棉花糖或牛油糖。如何解决这个问题,对不起,我的英语

附言:当我改变目标sdk到22或更高的时候,它很正常,没有强制关闭发生。

代码语言:javascript
复制
03-12 02:46:05.141 15526-15526/? I/art: Not late-enabling -Xcheck:jni (already on)
03-12 02:46:05.205 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.220 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.250 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.262 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.273 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.283 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.294 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.303 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.312 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.329 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.339 15526-15526/com.ringdroid W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/app/com.ringdroid-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/x86/data@app@com.ringdroid-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
03-12 02:46:05.340 15526-15526/com.ringdroid W/System: ClassLoader referenced unknown path: /data/app/com.ringdroid-1/lib/x86
03-12 02:46:05.341 15526-15526/com.ringdroid I/InstantRun: Starting Instant Run Server for com.ringdroid
03-12 02:51:21.753 15526-20262/com.ringdroid D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
03-12 02:51:21.766 15526-20260/com.ringdroid E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                               Process: com.ringdroid, PID: 15526
                                                               java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                   at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                   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:1113)
                                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                   at java.lang.Thread.run(Thread.java:818)
                                                                Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=15526, uid=10124 requires android.permission.READ_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.query(ContentProviderNative.java:421)
                                                                   at android.content.ContentResolver.query(ContentResolver.java:491)
                                                                   at android.content.CursorLoader.loadInBackground(CursorLoader.java:64)
                                                                   at android.content.CursorLoader.loadInBackground(CursorLoader.java:56)
                                                                   at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:312)
                                                                   at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:69)
                                                                   at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:66)
                                                                   at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                   at java.lang.Thread.run(Thread.java:818) 
03-12 02:51:22.079 15526-20262/com.ringdroid I/OpenGLRenderer: Initialized EGL, version 1.4
03-12 02:51:22.240 15526-20262/com.ringdroid E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaaa72470
03-12 02:56:22.073 15526-20260/com.ringdroid I/Process: Sending signal. PID: 15526 SIG: 9
EN

回答 2

Stack Overflow用户

发布于 2017-03-12 04:09:43

这根本不是一个bug。您需要从API 23开始将权限处理正确添加到您的代码中。

如果设备运行的是Android6.0或更高版本,您的应用程序的目标SDK为23或更高:应用程序必须在清单中列出权限,并且必须在应用程序运行时请求所需的每个危险权限

Android | Requesting Permissions at Run Time

票数 0
EN

Stack Overflow用户

发布于 2017-03-12 04:39:36

这是一个解决你问题的教程:

https://developer.android.com/training/permissions/requesting.html

并在此基础上给出一个快速答案:

更新您的清单以声明必要的权限:

代码语言:javascript
复制
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

然后,在执行启动asyncTask的代码之前,请检查您是否具有读取外部文件的权限。如果没有,请向用户请求该权限:

代码语言:javascript
复制
// Here you check if you have the permission
if (ContextCompat.checkSelfPermission(thisActivity,
        Manifest.permission.READ_EXTERNAL_STORAGE)
        != PackageManager.PERMISSION_GRANTED) {

        // Here you ask for it
        ActivityCompat.requestPermissions(thisActivity,
                new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                MY_REQUEST_CODE);

    }
}

然后,当用户决定是否授予您权限时,android系统将通知您的活动。只有在用户接受的情况下,您的任务才会在以下回调中启动。

代码语言:javascript
复制
@Override
public void onRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
        switch (requestCode) {
            case MY_REQUEST_CODE: {
                // If request is cancelled, the result arrays are empty.
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                // permission was granted, yay! Do the
                // task you need to do.

                } else {

                // permission denied, boo! Disable the
                // functionality that depends on this permission.
                }
        }

    }
}

当然,系统允许你做更高级的事情,比如如果用户一直拒绝你的请求,就会显示一个提示。

我希望这对你有所帮助,如果你还有其他问题,请不要犹豫地回复

附言:看看RxJava和翻新。它们是用于并发和网络的两个库,它们无缝地协同工作,并使异步任务过时。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42740009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档