{"record":{"id":"141b27a4e345046f","repo":"Tencent/QMUI_Android","slug":"the-skin-does-not-exist","errorCode":null,"errorMessage":"The skin  does not exist","messagePattern":"The skin  does not exist","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"qmui/src/main/java/com/qmuiteam/qmui/skin/QMUISkinManager.java","lineNumber":276,"sourceCode":"        Object current = view.getTag(R.id.qmui_skin_current);\n        if (current instanceof ViewSkinCurrent) {\n            return (ViewSkinCurrent) current;\n        }\n        return null;\n    }\n\n    public void dispatch(View view, int skinIndex) {\n        if (view == null) {\n            return;\n        }\n        if (QMUIConfig.DEBUG) {\n            Trace.beginSection(\"QMUISkin::dispatch\");\n        }\n        SkinItem skinItem = mSkins.get(skinIndex);\n        Resources.Theme theme;\n        if (skinItem == null) {\n            if (skinIndex != DEFAULT_SKIN) {\n                throw new IllegalArgumentException(\"The skin \" + skinIndex + \" does not exist\");\n            }\n            theme = view.getContext().getTheme();\n        } else {\n            theme = skinItem.getTheme();\n        }\n        runDispatch(view, skinIndex, theme);\n        if (QMUIConfig.DEBUG) {\n            Trace.endSection();\n        }\n    }\n\n\n    private void runDispatch(@NonNull View view, int skinIndex, Resources.Theme theme) {\n        ViewSkinCurrent currentTheme = getViewSkinCurrent(view);\n        if (currentTheme != null && currentTheme.index == skinIndex && Objects.equals(currentTheme.managerName, mName)) {\n            return;\n        }\n        view.setTag(R.id.qmui_skin_current, new ViewSkinCurrent(mName, skinIndex));","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/qmui/src/main/java/com/qmuiteam/qmui/skin/QMUISkinManager.java#L258-L294","documentation":"QMUISkinManager.dispatch(view, skinIndex) looks up the registered SkinItem for skinIndex; if none is registered and the index is not DEFAULT_SKIN, it throws an IllegalArgumentException because there is no theme to apply to the view. The default skin (index 0) falls back to the view context's theme, but any other index must have been added via addSkin().","triggerScenarios":"Calling changeSkin(index) or a view being refreshed with a skin index that was never registered through addSkin(); passing a wrong index to QMUISkinViewHelper/refreshSkin; registering skins in one process/Activity but dispatching in another lifecycle.","commonSituations":"saveSkinIndex persisted an index from a previous app version whose skins are no longer registered at startup; changeSkin called before addSkin calls complete; typo in index constant.","solutions":["Call addSkin(index, styleRes) for every index you can changeSkin() to, before changeSkin is invoked.","Validate the persisted skin index at startup and fall back to QMUISkinManager.DEFAULT_SKIN if it is not registered.","Guard manual changeSkin calls with mSkins awareness — only allow switching to known indices.","Wrap changeSkin in try-catch (IllegalArgumentException) and fall back to the default skin."],"exampleFix":"// before\nskinManager.changeSkin(2); // skin 2 never registered\n\n// after\nskinManager.addSkin(2, R.style.Skin_Dark);\nskinManager.changeSkin(2);","handlingStrategy":"fallback","validationCode":"Set<Integer> known = new ArraySet<>(); // track indices passed to addSkin\nif (index == QMUISkinManager.DEFAULT_SKIN || known.contains(index)) {\n    skinManager.changeSkin(index);\n}","typeGuard":"boolean isSkinRegistered(int index, Set<Integer> registered) {\n    return index == QMUISkinManager.DEFAULT_SKIN || registered.contains(index);\n}","tryCatchPattern":"try {\n    skinManager.changeSkin(savedIndex);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"skin \" + savedIndex + \" missing, falling back\", e);\n    skinManager.changeSkin(QMUISkinManager.DEFAULT_SKIN);\n}","preventionTips":["Register all skins with addSkin before any changeSkin call","Sanitize persisted skin indices at startup and fall back to DEFAULT_SKIN","Track registered indices in a Set for validation","Share one SkinManager instance and registration path across screens"],"tags":["android","qmui","skin","resource-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}