{"record":{"id":"ba42995c4b29cdf3","repo":"koral--/android-gif-drawable","slug":"expected-string-drawable-mipmap-or-raw-resource","errorCode":null,"errorMessage":"Expected string, drawable, mipmap or raw resource type. '<resourceTypeName>' is not supported","messagePattern":"Expected string, drawable, mipmap or raw resource type\\. '<resourceTypeName>' is not supported","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java","lineNumber":149,"sourceCode":"\t * @param surfaceTexture ignored\n\t */\n\t@Override\n\tpublic void setSurfaceTexture(@NonNull SurfaceTexture surfaceTexture) {\n\t\tthrow new UnsupportedOperationException(\"Changing SurfaceTexture is not supported\");\n\t}\n\n\tprivate static InputSource findSource(final TypedArray textureViewAttributes) {\n\t\tfinal TypedValue value = new TypedValue();\n\t\tif (!textureViewAttributes.getValue(R.styleable.GifTextureView_gifSource, value)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (value.resourceId != 0) {\n\t\t\tfinal String resourceTypeName = textureViewAttributes.getResources().getResourceTypeName(value.resourceId);\n\t\t\tif (GifViewUtils.SUPPORTED_RESOURCE_TYPE_NAMES.contains(resourceTypeName)) {\n\t\t\t\treturn new InputSource.ResourcesSource(textureViewAttributes.getResources(), value.resourceId);\n\t\t\t} else if (!\"string\".equals(resourceTypeName)) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"Expected string, drawable, mipmap or raw resource type. '\" + resourceTypeName\n\t\t\t\t\t\t\t\t+ \"' is not supported\");\n\t\t\t}\n\t\t}\n\t\treturn new InputSource.AssetSource(textureViewAttributes.getResources().getAssets(), value.string.toString());\n\t}\n\n\tprivate static class RenderThread extends Thread implements SurfaceTextureListener {\n\n\t\tfinal ConditionVariable isSurfaceValid = new ConditionVariable();\n\t\tprivate GifInfoHandle mGifInfoHandle = new GifInfoHandle();\n\t\tprivate IOException mIOException;\n\t\tlong[] mSavedState;\n\t\tprivate final WeakReference<GifTextureView> mGifTextureViewReference;\n\n\t\tRenderThread(final GifTextureView gifTextureView) {\n\t\t\tsuper(\"GifRenderThread\");\n\t\t\tmGifTextureViewReference = new WeakReference<>(gifTextureView);","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java#L131-L167","documentation":"GifTextureView resolves the XML attribute referencing a GIF source. When android:src (or the library's gifSource attribute) is set to a resource ID, it checks the resource type name via Resources.getResourceTypeName(). Only 'drawable', 'mipmap' and 'raw' resource types are valid GIF sources; 'string' falls back to treating the value as an asset filename. Any other resource type (e.g. 'array', 'bool', 'id', 'layout') makes the view throw this IllegalArgumentException from findSource, called during init.","triggerScenarios":"Setting the GifTextureView source attribute in XML (app:gifSource or android:src with a resource ID) to a resource whose type is not drawable/mipmap/raw/string — for example @array/..., @layout/..., @bool/..., or an ID-type resource passed programmatically via attributes.","commonSituations":"Developers placing GIF files under the wrong res/ folder (e.g. res/xml or res/raw misspelled), referencing the wrong @ resource by autocomplete accident, or using a data-binding/generated ID that points to a non-media resource type. Most commonly it is a typo in the resource qualifier (@drawble, @rawr) so the resource resolves to an unexpected type.","solutions":["Move the GIF into res/drawable (or drawable-nodpi), res/raw, or res/mipmap and reference it with @drawable/..., @raw/... or @mipmap/...","If the GIF is an asset instead, keep the attribute as a string literal (e.g. app:gifSource=\"gifs/anim.gif\") pointing at the file inside src/main/assets","Check the attribute value for typos in the resource type prefix — an unrecognized prefix can resolve to the wrong resource type","Verify the resource ID actually belongs to your media resource (print getResources().getResourceTypeName(id) while debugging)"],"exampleFix":"<!-- before -->\n<pl.droidsonroids.gif.GifTextureView\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    app:gifSource=\"@array/gif_names\" />\n\n<!-- after -->\n<pl.droidsonroids.gif.GifTextureView\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    app:gifSource=\"@raw/animation\" />","handlingStrategy":"validation","validationCode":"// Kotlin: verify the resource type before assigning to GifTextureView\nfun isSupportedGifSource(res: Resources, @AnyRes resId: Int): Boolean {\n    val type = res.getResourceTypeName(resId)\n    return type in setOf(\"drawable\", \"mipmap\", \"raw\", \"string\")\n}\n// usage: require(isSupportedGifSource(resources, R.raw.animation))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep GIF files in res/raw or res/drawable(-nodpi) only","Prefer app:gifSource with @raw/... references to avoid asset/type ambiguity","Lint-check resource references used in gifSource attributes at build time"],"tags":["android","resource-type","illegal-argument","xml-attribute"],"backgroundTag":"unsupported-resource-type","analyzedSha":"26ff795f78b7fe8bbaf375a947b2bda95fc58e3d","analyzedAt":"2026-09-10T14:37:11.595Z","contentChangedAt":"2026-09-10T14:37:11.595Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}