Tencent/QMUI_Android · error · IllegalArgumentException

The skin does not exist

Error message

The skin  does not exist

What it means

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().

Source

Thrown at qmui/src/main/java/com/qmuiteam/qmui/skin/QMUISkinManager.java:276

        Object current = view.getTag(R.id.qmui_skin_current);
        if (current instanceof ViewSkinCurrent) {
            return (ViewSkinCurrent) current;
        }
        return null;
    }

    public void dispatch(View view, int skinIndex) {
        if (view == null) {
            return;
        }
        if (QMUIConfig.DEBUG) {
            Trace.beginSection("QMUISkin::dispatch");
        }
        SkinItem skinItem = mSkins.get(skinIndex);
        Resources.Theme theme;
        if (skinItem == null) {
            if (skinIndex != DEFAULT_SKIN) {
                throw new IllegalArgumentException("The skin " + skinIndex + " does not exist");
            }
            theme = view.getContext().getTheme();
        } else {
            theme = skinItem.getTheme();
        }
        runDispatch(view, skinIndex, theme);
        if (QMUIConfig.DEBUG) {
            Trace.endSection();
        }
    }


    private void runDispatch(@NonNull View view, int skinIndex, Resources.Theme theme) {
        ViewSkinCurrent currentTheme = getViewSkinCurrent(view);
        if (currentTheme != null && currentTheme.index == skinIndex && Objects.equals(currentTheme.managerName, mName)) {
            return;
        }
        view.setTag(R.id.qmui_skin_current, new ViewSkinCurrent(mName, skinIndex));

View on GitHub (pinned to 026e7d4866)

Solutions

  1. Call addSkin(index, styleRes) for every index you can changeSkin() to, before changeSkin is invoked.
  2. Validate the persisted skin index at startup and fall back to QMUISkinManager.DEFAULT_SKIN if it is not registered.
  3. Guard manual changeSkin calls with mSkins awareness — only allow switching to known indices.
  4. Wrap changeSkin in try-catch (IllegalArgumentException) and fall back to the default skin.

Example fix

// before
skinManager.changeSkin(2); // skin 2 never registered

// after
skinManager.addSkin(2, R.style.Skin_Dark);
skinManager.changeSkin(2);
Defensive patterns

Strategy: fallback

Validate before calling

Set<Integer> known = new ArraySet<>(); // track indices passed to addSkin
if (index == QMUISkinManager.DEFAULT_SKIN || known.contains(index)) {
    skinManager.changeSkin(index);
}

Type guard

boolean isSkinRegistered(int index, Set<Integer> registered) {
    return index == QMUISkinManager.DEFAULT_SKIN || registered.contains(index);
}

Try / catch

try {
    skinManager.changeSkin(savedIndex);
} catch (IllegalArgumentException e) {
    Log.w(TAG, "skin " + savedIndex + " missing, falling back", e);
    skinManager.changeSkin(QMUISkinManager.DEFAULT_SKIN);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06). Data as JSON: /api/errors/141b27a4e345046f. Report an issue: GitHub.