Tencent/QMUI_Android · error · IllegalStateException

FragmentScheme#activities can not be empty.

Error message

FragmentScheme#activities can not be empty.

What it means

SchemeProcessor.generateFragmentHostActivityList requires every FragmentScheme to declare at least one host activity via the activities element. When the array is null or empty the processor throws this IllegalStateException, aborting annotation processing.

Source

Thrown at arch-compiler/src/main/java/com/qmuiteam/qmui/arch/SchemeProcessor.java:393

        }

        return CodeBlock.of("$T.class", typeMirror);
    }

    private CodeBlock generateFragmentHostActivityList(FragmentScheme fragmentScheme){
        CodeBlock.Builder builder = CodeBlock.builder();
        TypeMirror[] activities = null;
        try {
            fragmentScheme.activities();
        } catch (MirroredTypesException mte) {
            List<? extends TypeMirror> containerMirrors = mte.getTypeMirrors();
            activities = new TypeMirror[containerMirrors.size()];
            for (int i = 0; i < activities.length; i++) {
                activities[i] = containerMirrors.get(i);
            }
        }
        if(activities == null || activities.length == 0){
            throw new IllegalStateException("FragmentScheme#activities can not be empty.");
        }
        builder.add("new $T[]{", OriginClassName);
        for(int i=0; i < activities.length; i++){
            TypeMirror item = activities[i];
            if(!isSubtypeOfType(item, QMUI_FRAGMENT_ACTIVITY_TYPE)){
                throw new IllegalStateException("FragmentScheme#activities must be QMUIFragmentActivity.");
            }
            if(i > 0){
                builder.add(",");
            }
            builder.add("$T.class", ClassName.get(item));
        }
        builder.add("}");
        return builder.build();
    }

    @Override
    public Set<String> getSupportedAnnotationTypes() {

View on GitHub (pinned to 026e7d4866)

Solutions

  1. Set activities = [YourActivity::class] (a QMUIFragmentActivity subclass) on the FragmentScheme annotation.
  2. Ensure the fragment is intended to be hosted inside a QMUIFragmentActivity; otherwise use a different scheme type.
  3. Re-run the build after filling the attribute.

Example fix

// before
@FragmentScheme(name = "page")
class DetailFragment : QMUIFragment() { ... }

// after
@FragmentScheme(name = "page", activities = [MainActivity::class])
class DetailFragment : QMUIFragment() { ... }
Defensive patterns

Strategy: validation

Validate before calling

// annotation-level check before compiling:
// every @FragmentScheme must declare non-empty activities
fun checkActivities(activities: List<Class<*>>) =
    check(activities.isNotEmpty()) { "FragmentScheme#activities can not be empty." }

Type guard

fun hasHostActivities(activities: Array<Class<*>>?): Boolean =
    !activities.isNullOrEmpty()

Prevention

When it happens

Trigger: Using @FragmentScheme (or equivalent) without setting activities, or explicitly passing an empty list/array of activity classes.

Common situations: Newly added scheme annotation copied without filling activities; conditional code accidentally removed the activities value; misunderstanding that the fragment must be hosted by a QMUIFragmentActivity.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — 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/c3a500bf768d91fc. Report an issue: GitHub.