使用目标SDK强制关闭

时间:2017-03-11 20:04:09

标签: java android ringdroid

我有这个来源的问题(Ringdroid:https://github.com/google/ringdroid),上个月我更新了我的应用程序,目标是在Android 23,但我只是意识到当我启动我的应用程序与Android 23,24,25它给我强迫关闭,所以我将我的目标sdk更改为22,但谷歌游戏商店说它可能发生,因为以前的版本针对23.问题是,这是一个错误?我需要我的项目针对Android 23,当我使用marsmallow或nougat使用模拟器或智能手机打开时仍然给我强制关闭。如何解决这个问题,抱歉我的英文

P.S。:当我将目标sdk改为22或更高时,它绝对正常,不会发生强制关闭。

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

2 个答案:

答案 0 :(得分:0)

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

  

如果设备运行Android 6.0或更高版本,您应用的目标SDK为23或更高:应用必须列出清单中的权限,它必须在应用运行时请求所需的每个危险权限

Android | Requesting Permissions at Run Time

答案 1 :(得分:0)

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

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

基于它的快速回答:

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

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

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

// 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系统将通知您的活动。仅当用户已接受时,才应在以下回调中启动您的任务。

@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.
                }
        }

    }
}

当然,系统可以让您执行更高级的操作,例如,如果用户不断拒绝您的请求,则显示提示。

如果您有其他问题,我希望这可以帮助您,并且不要犹豫回复

P.S。:看看RxJava并进行改造。它们是两个用于并发和网络的库,它们可以无缝地协同工作,并使asynctasks过时。

相关问题