Blankj/AndroidUtilCode · error · Exception
ApiExtension's apiUtilsClass is empty.
Error message
ApiExtension's apiUtilsClass is empty.
What it means
ApiPlugin.onScanStarted() reads ext.apiUtilsClass (ApiExtension default "com.blankj.utilcode.util.ApiUtils"). If, after trim(), the value is empty, it throws Exception. The plugin needs the fully-qualified ApiUtils class name to know which class to inject the registered impls into during transform.
Source
Thrown at plugin/api-gradle-plugin/src/main/java/com/blankj/api/ApiPlugin.groovy:30
class ApiPlugin extends BaseTransformPlugin<ApiExtension> {
String apiUtilsClass
File jsonFile
File apiUtilsTransformFile
Map<String, ApiInfo> apiImplMap = [:]
List<String> apiClasses = []
@Override
String getPluginName() {
return Config.EXT_NAME
}
@Override
void onScanStarted() {
apiUtilsClass = ext.apiUtilsClass
if (apiUtilsClass.trim().equals("")) {
throw new Exception("ApiExtension's apiUtilsClass is empty.")
}
jsonFile = new File(mProject.projectDir.getAbsolutePath(), "__api__.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
- Set apiUtilsClass to the fully-qualified name of your ApiUtils class, e.g. api { apiUtilsClass 'com.blankj.utilcode.util.ApiUtils' }.
- If you use AndroidUtilCode's built-in ApiUtils, remove the apiUtilsClass override so the default applies.
- Make sure no build logic assigns an empty/whitespace string to ext.apiUtilsClass.
Example fix
// before
api {
apiUtilsClass "" // -> "ApiExtension's apiUtilsClass is empty."
}
// after
api {
apiUtilsClass "com.blankj.utilcode.util.ApiUtils"
}
// or omit the api{} block entirely to use the default Defensive patterns
Strategy: validation
Validate before calling
afterEvaluate {
def extApi = project.extensions.findByName('api')
if (extApi == null || !extApi.apiUtilsClass?.trim()) {
throw new GradleException("api { apiUtilsClass '...' } must be set and non-blank.")
}
} Prevention
- Always pass a concrete fully-qualified class name to apiUtilsClass, never blank.
- If unsure, omit the api{} block and rely on the default com.blankj.utilcode.util.ApiUtils.
- Add an afterEvaluate assertion so a blank value fails your build early with a clear message.
When it happens
Trigger: Configuring the api{} DSL with apiUtilsClass set to an empty string or whitespace, e.g. api { apiUtilsClass "" }; or assigning a property that resolves to a blank value.
Common situations: Pointing the api extension at a custom ApiUtils class but leaving the path blank; a typo or cleared property; copy-pasting a config snippet that omitted the value.
Related errors
- <" + className + "> and <" + apiInfo.implApiClass + "> impl
- u should impl these apis: " + noImplApis + "\n u can check i
- No ApiUtils of ${apiUtilsClass} in $mProject.
- BusExtension's busUtilsClass is empty.
- These buses is not right: " + wrongBus + "\n u can check it
AI-assisted analysis of Blankj/AndroidUtilCode@7b4caf9e54 (2026-08-14).
Data as JSON: /api/errors/cbe6676d9b6fa98d.
Report an issue: GitHub.