Blankj/AndroidUtilCode · error · Exception

BusExtension's busUtilsClass is empty.

Error message

BusExtension's busUtilsClass is empty.

What it means

BusPlugin.onScanStarted() reads ext.busUtilsClass (BusExtension default "com.blankj.utilcode.util.BusUtils"). If, after trim(), the value is empty, it throws Exception. The plugin needs the BusUtils FQN to know which class to inject the event registry into during transform.

Source

Thrown at plugin/bus-gradle-plugin/src/main/java/com/blankj/bus/BusPlugin.groovy:29

import java.util.regex.Pattern

class BusPlugin extends BaseTransformPlugin<BusExtension> {

    String busUtilsClass
    File jsonFile
    Map<String, List<BusInfo>> busMap = [:]
    File busUtilsTransformFile

    @Override
    String getPluginName() {
        return Config.EXT_NAME
    }

    @Override
    void onScanStarted() {
        busUtilsClass = ext.busUtilsClass
        if (busUtilsClass.trim().equals("")) {
            throw new Exception("BusExtension's busUtilsClass is empty.")
        }

        jsonFile = new File(mProject.projectDir.getAbsolutePath(), "__bus__.json")
        FileUtils.write(jsonFile, "{}")
    }

    @Override
    boolean isIgnoreScan(JarInput input) {
        def jarName = input.name
        if (jarName.contains("utilcode")) {
            return false
        }

        if (ext.onlyScanLibRegex != null && ext.onlyScanLibRegex.trim().length() > 0) {
            return !Pattern.matches(ext.onlyScanLibRegex, jarName)
        }

        if (ext.jumpScanLibRegex != null && ext.jumpScanLibRegex.trim().length() > 0) {

View on GitHub (pinned to 7b4caf9e54)

Solutions

  1. Set busUtilsClass to the fully-qualified name of your BusUtils class, e.g. bus { busUtilsClass 'com.blankj.utilcode.util.BusUtils' }.
  2. If you use AndroidUtilCode's built-in BusUtils, remove the busUtilsClass override so the default applies.
  3. Make sure no build logic assigns an empty/whitespace string to ext.busUtilsClass.

Example fix

// before
bus {
    busUtilsClass "   "   // -> "BusExtension's busUtilsClass is empty."
}

// after
bus {
    busUtilsClass "com.blankj.utilcode.util.BusUtils"
}
// or omit the bus{} block entirely to use the default
Defensive patterns

Strategy: validation

Validate before calling

afterEvaluate {
    def extBus = project.extensions.findByName('bus')
    if (extBus == null || !extBus.busUtilsClass?.trim()) {
        throw new GradleException("bus { busUtilsClass '...' } must be set and non-blank.")
    }
}

Prevention

When it happens

Trigger: Configuring the bus{} DSL with busUtilsClass set to an empty string or whitespace, e.g. bus { busUtilsClass "" }; or assigning a property that resolves to a blank value.

Common situations: Pointing the bus extension at a custom BusUtils class but leaving the path blank; a typo or cleared property; copy-pasting a config snippet that omitted the value.

Related errors


AI-assisted analysis of Blankj/AndroidUtilCode@7b4caf9e54 (2026-08-14). Data as JSON: /api/errors/fc5f1c035552cfe5. Report an issue: GitHub.