当我将位图转换为WEBP格式时,我的Android应用程序给了我这个错误:
#00 pc 00000000004125c4 /system/lib/libskia.so
#01 pc 000000000042e350 /system/lib/libskia.so
#02 pc 000000000042db78 /system/lib/libskia.so
#03 pc 000000000042dc60 /system/lib/libskia.so (WebPPictureImportRGBA+36)
#04 pc 00000000003a1fd0 /system/lib/libskia.so (_ZN18SkWEBPImageEncoder8onEncodeEP9SkWStreamRK8SkBitmapi+444)
#05 pc 00000000000a216f /system/lib/libandroid_runtime.so
#06 pc 0000000001aabea3 /system/framework/arm/boot-framework.oat (android.graphics.Bitmap.nativeCompress+158)
#07 pc 0000000001aad39b /system/framework/arm/boot-framework.oat (android.graphics.Bitmap.compress+230)
#08 pc 00000000000a9e41 /system/lib/libart.so (art_quick_invoke_stub_internal+64)
#09 pc 00000000004087e1 /system/lib/libart.so (art_quick_invoke_stub+232)
#10 pc 00000000000b1115 /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+136)
#11 pc 00000000001ef3fd /system/lib/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+200)
#12 pc 00000000001e99ad /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+492)
#13 pc 0000000000402bb3 /system/lib/libart.so (MterpInvokeVirtualQuick+322)
#14 pc 00000000000a0a14 /system/lib/libart.so (ExecuteMterpImpl+29972)
#15 pc 00000000001cc463 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
#16 pc 00000000001d0fcb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
#17 pc 00000000001e9993 /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
#18 pc 0000000000402bb3 /system/lib/libart.so (MterpInvokeVirtualQuick+322)
#19 pc 00000000000a0a14 /system/lib/libart.so (ExecuteMterpImpl+29972)
#20 pc 00000000001cc463 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
#21 pc 00000000001d0fcb /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+114)
#22 pc 00000000001e9993 /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+466)
#23 pc 0000000000402bb3 /system/lib/libart.so (MterpInvokeVirtualQuick+322)
#24 pc 00000000000a0a14 /system/lib/libart.so (ExecuteMterpImpl+29972)
#25 pc 00000000001cc463 /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+290)
#26 pc 00000000001d0f35 /system/lib/libart.so (_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameE+92)
#27 pc 00000000003f7bb3 /system/lib/libart.so (artQuickToInterpreterBridge+706)
#28 pc 00000000000ae893 /system/lib/libart.so (art_quick_to_interpreter_bridge+34)
#29 pc 000000000208fc09 /system/framework/arm/boot-framework.oat (android.view.View.performClick+276)
#30 pc 0000000002109f95 /system/framework/arm/boot-framework.oat (android.view.View$PerformClick.run+40)
#31 pc 000000000182fbe5 /system/framework/arm/boot-framework.oat (android.os.Handler.handleCallback+48)
#32 pc 000000000182fc43 /system/framework/arm/boot-framework.oat (android.os.Handler.dispatchMessage+54)
#33 pc 0000000001e24e39 /system/framework/arm/boot-framework.oat (android.os.Looper.loop+1948)
#34 pc 00000000018445f3 /system/framework/arm/boot-framework.oat (android.app.ActivityThread.main+814)
#35 pc 00000000000a9e41 /system/lib/libart.so (art_quick_invoke_stub_internal+64)
#36 pc 00000000004088e9 /system/lib/libart.so (art_quick_invoke_static_stub+228)
#37 pc 00000000000b113f /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+178)
#38 pc 0000000000318d21 /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+56)
#39 pc 000000000031a0b3 /system/lib/libart.so (_ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_j+766)
#40 pc 00000000002c12d5 /system/lib/libart.so (_ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_S3_+40)
#41 pc 00000000005ae931 /system/framework/arm/boot-core-oj.oat (java.lang.reflect.Method.invoke+116)
#42 pc 000000000236cf89 /system/framework/arm/boot-framework.oat (com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run+100)
#43 pc 000000000236e3df /system/framework/arm/boot-framework.oat (com.android.internal.os.ZygoteInit.main+1978)
#44 pc 00000000000a9e41 /system/lib/libart.so (art_quick_invoke_stub_internal+64)
#45 pc 00000000004088e9 /system/lib/libart.so (art_quick_invoke_static_stub+228)
#46 pc 00000000000b113f /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+178)
#47 pc 0000000000318d21 /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+56)
#48 pc 0000000000318b33 /system/lib/libart.so (_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDSt9__va_list+266)
#49 pc 000000000027b61f /system/lib/libart.so (_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+426)
#50 pc 000000000006837d /system/lib/libandroid_runtime.so
#51 pc 0000000000069c63 /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime5startEPKcRKNS_6VectorINS_7String8EEEb+498)
#52 pc 000000000000199f /system/bin/app_process32
#53 pc 0000000000016d8d /system/lib/libc.so (__libc_init+48)
#54 pc 00000000000015bc /system/bin/app_process32
我不知道确切的错误发生在哪里,但是我的猜测是当我尝试在此处尝试将位图压缩为WEBP格式时:
public String saveImage(String id, Bitmap bitmap) {
if(bitmap != null) {
File folder = new File(getFilesDir() + "/packs", id);
if (!folder.exists())
folder.mkdirs();
String stickerName = "sticker" + String.valueOf(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())) + ".webp";
File filename = new File(folder, stickerName);
try {
if (!filename.exists())
filename.createNewFile();
FileOutputStream out = new FileOutputStream(filename);
bitmap.compress(Bitmap.CompressFormat.WEBP, 100, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
return stickerName;
} else {
return null;
}
}
位图是在我的自定义视图中创建的,然后保存为WEBP,但是每次尝试都会给我一个错误。正如我说的,我不知道如何调试此错误消息,所以如果我完全错了,请说。
提前致谢!
最佳答案
所以我最终使用了libwebp而不是Bitmap.compress(Bitmap.CompressFormat.WEBP, 100, out);
,它现在可以正常工作了。这是有关如何使用libwebp http://masashi-k.blogspot.com/2014/02/webp-in-android.html的教程。
关于android - 位图转换为webp给出信号11,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53284295/