Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t使用try-catch、createBitmap捕获Java(Android)异常_Android_Exception_Android Bitmap - Fatal编程技术网

Can';t使用try-catch、createBitmap捕获Java(Android)异常

Can';t使用try-catch、createBitmap捕获Java(Android)异常,android,exception,android-bitmap,Android,Exception,Android Bitmap,我有一部分代码,我使用这段代码四次,但第六次,我的应用程序崩溃,我没有得到任何异常或错误代码。代码是: Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); 我尝试使用: try{ Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); }catch (Exc

我有一部分代码,我使用这段代码四次,但第六次,我的应用程序崩溃,我没有得到任何异常或错误代码。代码是:

Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
我尝试使用:

try{

Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);

    }catch (Exception e){
        e.printStackTrace();
        e.getMessage();
    }catch (OutOfMemoryError o){
        o.printStackTrace();
        o.getMessage();
    }catch (AssertionError a){
        a.printStackTrace();
        a.getMessage();
    } catch ( Throwable t ){
        t.printStackTrace();
        t.getMessage();
    }
但是什么也没发生。我在不同的处理程序中测试我的应用程序,在索尼Xperia Z3、Moto G和GenyMotion中使用不同的模拟器都能很好地工作

但不要在我的摩托罗拉Moto Max中工作

日志控制台不显示错误,但打印一些代码:

  --------- beginning of main
08-11 15:34:55.589    6258-6258/? E/Diag_Lib﹕ Diag_LSM_Init: Failed to open handle to diag driver, error = 2
08-11 15:35:00.638    6275-6275/? E/Diag_Lib﹕ Diag_LSM_Init: Failed to open handle to diag driver, error = 2
    --------- beginning of system
08-11 15:35:00.723     817-1225/? V/AlarmManager﹕ send {ea59bfe, *alarm*:android.intent.action.TIME_TICK}
08-11 15:35:00.723     817-1225/? V/AlarmManager﹕ send {26ca6698, *alarm*:com.google.android.gms/.lockbox.LockboxAlarmReceiver}
08-11 15:35:00.748      817-817/? V/AlarmManager﹕ done {26ca6698, *alarm*:com.google.android.gms/.lockbox.LockboxAlarmReceiver} [26ms]
    --------- beginning of crash
08-11 15:35:00.937    5910-5951/garagecoders.tecnoblinds.main A/libc﹕ Fatal signal 11 (SIGSEGV), code 2, fault addr 0xaf1f9000 in tid 5951 (AsyncTask #1)
08-11 15:35:00.946      817-817/? V/AlarmManager﹕ done {ea59bfe, *alarm*:android.intent.action.TIME_TICK} [224ms]
08-11 15:35:01.039      348-348/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-11 15:35:01.039      348-348/? I/DEBUG﹕ Build fingerprint: 'motorola/quark_retla/quark_umts:5.0.2/LXG22.33-12.16/16:user/release-keys'
08-11 15:35:01.039      348-348/? I/DEBUG﹕ Revision: 'p4a0'
08-11 15:35:01.039      348-348/? I/DEBUG﹕ ABI: 'arm'
08-11 15:35:01.040      348-348/? I/DEBUG﹕ pid: 5910, tid: 5951, name: AsyncTask #1  >>> garagecoders.tecnoblinds.main <<<
08-11 15:35:01.040      348-348/? I/DEBUG﹕ signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xaf1f9000
08-11 15:35:01.068      348-348/? I/DEBUG﹕ r0 00000004  r1 af1f8ffc  r2 024760c6  r3 f5d0f000
08-11 15:35:01.068      348-348/? I/DEBUG﹕ r4 b4873340  r5 000061cd  r6 00000247  r7 000002fb
08-11 15:35:01.068      348-348/? I/DEBUG﹕ r8 00000248  r9 00004000  sl 00000000  fp 00003ff0
08-11 15:35:01.069      348-348/? I/DEBUG﹕ ip af1f9000  sp a0f3d078  lr 00000247  pc b5af8014  cpsr 200b0010
08-11 15:35:01.069      348-348/? I/DEBUG﹕ backtrace:
08-11 15:35:01.069      348-348/? I/DEBUG﹕ #00 pc 001bd014  /system/lib/libskia.so (NofilterDXExecutionBuffer::GenerateUpscaleProgram(int, int, int, int)+128)
08-11 15:35:01.069      348-348/? I/DEBUG﹕ #01 pc 001bdcfc  /system/lib/libskia.so (NofilterDXExecutionBuffer::GenerateProgram(int, int, int, int)+92)
08-11 15:35:01.070      348-348/? I/DEBUG﹕ #02 pc 001bddf4  /system/lib/libskia.so (NfDXEBCache::prepareShaderProc32(int, int, int, int)+232)
08-11 15:35:01.070      348-348/? I/DEBUG﹕ #03 pc 001ba4d8  /system/lib/libskia.so (SkBitmapProcState::beginRect(int, int, int)+424)
08-11 15:35:01.070      348-348/? I/DEBUG﹕ #04 pc 001bade8  /system/lib/libskia.so (SkARGB32_Shader_Blitter::blitRect(int, int, int, int)+1244)
08-11 15:35:01.070      348-348/? I/DEBUG﹕ #05 pc 0010616b  /system/lib/libskia.so
08-11 15:35:01.070      348-348/? I/DEBUG﹕ #06 pc 00106237  /system/lib/libskia.so (SkScan::FillIRect(SkIRect const&, SkRegion const*, SkBlitter*)+198)
08-11 15:35:01.070      348-348/? I/DEBUG﹕ #07 pc 00106307  /system/lib/libskia.so (SkScan::FillRect(SkRect const&, SkRegion const*, SkBlitter*)+136)
08-11 15:35:01.070      348-348/? I/DEBUG﹕ #08 pc 001063f7  /system/lib/libskia.so (SkScan::FillRect(SkRect const&, SkRasterClip const&, SkBlitter*)+56)
08-11 15:35:01.071      348-348/? I/DEBUG﹕ #09 pc 000e2037  /system/lib/libskia.so (SkDraw::drawRect(SkRect const&, SkPaint const&) const+258)
08-11 15:35:01.071      348-348/? I/DEBUG﹕ #10 pc 000e3513  /system/lib/libskia.so (SkDraw::drawBitmap(SkBitmap const&, SkMatrix const&, SkPaint const&) const+276)
08-11 15:35:01.071      348-348/? I/DEBUG﹕ #11 pc 000cb863  /system/lib/libskia.so (SkBitmapDevice::drawBitmapRect(SkDraw const&, SkBitmap const&, SkRect const*, SkRect const&, SkPaint const&, SkCanvas::DrawBitmapRectFlags)+530)
08-11 15:35:01.071      348-348/? I/DEBUG﹕ #12 pc 000db98f  /system/lib/libskia.so (SkCanvas::internalDrawBitmapRect(SkBitmap const&, SkRect const*, SkRect const&, SkPaint const*, SkCanvas::DrawBitmapRectFlags)+210)
08-11 15:35:01.071      348-348/? I/DEBUG﹕ #13 pc 00093661  /system/lib/libandroid_runtime.so (android::SkiaCanvas::drawBitmap(SkBitmap const&, float, float, float, float, float, float, float, float, SkPaint const*)+58)
08-11 15:35:01.071      348-348/? I/DEBUG﹕ #14 pc 0008945d  /system/lib/libandroid_runtime.so
08-11 15:35:01.071      348-348/? I/DEBUG﹕ #15 pc 0089eeff  /system/framework/arm/boot.oat
-----------主程序的开头
08-11 15:34:55.589    6258-6258/? 电子/诊断库﹕ Diag_LSM_Init:无法打开Diag驱动程序的句柄,错误=2
08-11 15:35:00.638    6275-6275/? 电子/诊断库﹕ Diag_LSM_Init:无法打开Diag驱动程序的句柄,错误=2
---------系统开始
08-11 15:35:00.723     817-1225/? V/AlarmManager﹕ 发送{ea59bfe,*报警*:android.intent.action.TIME_TICK}
08-11 15:35:00.723     817-1225/? V/AlarmManager﹕ 发送{26ca6698,*alarm*:com.google.android.gms/.lockbox.LockboxAlarmReceiver}
08-11 15:35:00.748      817-817/? V/AlarmManager﹕ 完成{26ca6698,*alarm*:com.google.android.gms/.lockbox.LockboxAlarmReceiver}[26ms]
---------坠机开始
08-11 15:35:00.937 5910-5951/garagecoders.technoblinds.main A/libc﹕ tid 5951中的致命信号11(SIGSEGV),代码2,故障地址0xaf1f9000(异步任务1)
08-11 15:35:00.946      817-817/? V/AlarmManager﹕ 完成{ea59bfe,*报警*:android.intent.action.TIME_TICK}[224ms]
08-11 15:35:01.039      348-348/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-11 15:35:01.039      348-348/? I/DEBUG﹕ 构建指纹:“摩托罗拉/quark_retla/quark_umts:5.0.2/LXG22.33-12.16/16:用户/释放密钥”
08-11 15:35:01.039      348-348/? I/DEBUG﹕ 修订:“p4a0”
08-11 15:35:01.039      348-348/? I/DEBUG﹕ 阿比:“手臂”

08-11 15:35:01.040 348-348/? I/DEBUG﹕ pid:5910,tid:5951,name:AsyncTask#1>>>garagecoders.tecnoblinds.main我很确定您的设备内存不足,这就是为什么第6个CreateB位图将使您的应用程序崩溃的原因。请尝试以下操作:

try{
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
} catch (Exception e) {
    e.printStackTrace();
} catch (OutOfMemoryError e) {
    e.printStackTrace();
}
这将正确地为抛出的错误提供输出。让我知道输出,您可能需要手动调用System.gc()来处理自己的所有垃圾收集


阅读以下内容:

我很确定您的设备内存不足,这就是为什么第6个createBitmap会使您的应用程序崩溃的原因。请尝试以下操作:

try{
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
} catch (Exception e) {
    e.printStackTrace();
} catch (OutOfMemoryError e) {
    e.printStackTrace();
}
这将正确地为抛出的错误提供输出。让我知道输出,您可能需要手动调用System.gc()来处理自己的所有垃圾收集


阅读以下内容:

OutOfMemoryError和Exception extends of throwable,必须由}catch(throwable e){}处理,我对其他处理程序(如Moto G)没有问题。。。。还有MOTOMAX,有更多的ram内存…OutOfMemoryError和throwable的异常扩展,必须由}catch(throwable e){}处理,我对其他像MOTOG这样的处理程序没有问题。。。。还有Moto MAx,有更多的内存。。。