{"record":{"id":"aeb601b48194ab97","repo":"ZCShou/GoGoGo","slug":"unsupported-drawable-type","errorCode":null,"errorMessage":"unsupported drawable type","messagePattern":"unsupported drawable type","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/zcshou/joystick/RockerView.java","lineNumber":200,"sourceCode":"    }\n\n    private static Bitmap getBitmap(VectorDrawable vectorDrawable) {\n        Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),\n                vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);\n        Canvas canvas = new Canvas(bitmap);\n        vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());\n        vectorDrawable.draw(canvas);\n        return bitmap;\n    }\n\n    private static Bitmap getBitmap(Context context, int drawableId) {\n        Drawable drawable = ContextCompat.getDrawable(context, drawableId);\n        if (drawable instanceof BitmapDrawable) {\n            return BitmapFactory.decodeResource(context.getResources(), drawableId);\n        } else if (drawable instanceof VectorDrawable) {\n            return getBitmap((VectorDrawable) drawable);\n        } else {\n            throw new IllegalArgumentException(\"unsupported drawable type\");\n        }\n    }\n\n    private Bitmap scaleBitmap(Bitmap bitmap) {\n        Matrix mMatrix = new Matrix();\n        mMatrix.postScale(0.45f,0.45f);\n        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mMatrix,true);\n    }\n\n    private void toggleLockCtrl() {\n        Bitmap bitmap;\n\n        isAuto = !isAuto;\n\n        if (isAuto) {\n            bitmap = getBitmap(getContext(), R.drawable.ic_lock_close);\n        } else {\n            bitmap = getBitmap(getContext(), R.drawable.ic_lock_open);","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/ZCShou/GoGoGo/blob/de0d596190c57b8ca71481f60ce6b9e50af5107f/app/src/main/java/com/zcshou/joystick/RockerView.java#L182-L218","documentation":"A deliberate type guard in RockerView.getBitmap(Context, int): the helper can only rasterize drawables that resolve to BitmapDrawable or VectorDrawable. When ContextCompat.getDrawable returns any other Drawable subclass (e.g. AnimatedVectorDrawable, ColorDrawable, or a state/layer-list wrapper), no conversion path exists and an IllegalArgumentException is thrown. It fires while init or toggleLockCtrl loads a joystick image, meaning a referenced drawable resource resolved to an unsupported type.","triggerScenarios":"Thrown at app/src/main/java/com/zcshou/joystick/RockerView.java:200 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the referenced resource with a bitmap asset (PNG/JPEG/webp) or a plain <vector> VectorDrawable.","Add a branch for the actual Drawable subtype encountered (e.g. AnimatedVectorDrawable, PictureDrawable) and rasterize it instead of throwing.","If the id may point to a StateListDrawable or LayerListDrawable, unwrap it (e.g. stateList.getDrawable(0)) and dispatch on the child's type.","Handle the failure at the init/toggleLockCtrl call sites and fall back to a default joystick bitmap so a bad resource degrades gracefully."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"de0d596190c57b8ca71481f60ce6b9e50af5107f","analyzedAt":"2026-09-09T10:08:54.154Z","contentChangedAt":"2026-09-09T10:08:54.154Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}