Tencent/QMUI_Android · error · RuntimeException
Can not access the Class SchemeMapImpl. Please file a issue
Error message
Can not access the Class SchemeMapImpl. Please file a issue to report this.
What it means
QMUISchemeHandler's companion init reflectively instantiates the generated class SchemeMapImpl (produced by the arch-compiler SchemeProcessor). If Class.newInstance() raises IllegalAccessException — e.g. the class or its constructor is not accessible from the caller's classloader — the library wraps it in this RuntimeException and asks you to file an issue.
Source
Thrown at arch/src/main/java/com/qmuiteam/qmui/arch/scheme/QMUISchemeHandler.kt:47
const val ARG_FINISH_CURRENT = "__qmui_finish_current"
private var sSchemeMap: SchemeMap? = null
init {
try {
val cls = Class.forName(SchemeMap::class.java.name + "Impl")
sSchemeMap = cls.newInstance() as SchemeMap
} catch (e: ClassNotFoundException) {
sSchemeMap = object : SchemeMap {
override fun findScheme(handler: QMUISchemeHandler, schemeAction: String, params: Map<String, String>?): SchemeItem? {
return null
}
override fun exists(handler: QMUISchemeHandler, schemeAction: String): Boolean {
return false
}
}
} catch (e: IllegalAccessException) {
throw RuntimeException(
"Can not access the Class SchemeMapImpl. " +
"Please file a issue to report this."
)
} catch (e: InstantiationException) {
throw RuntimeException(
"Can not instance the Class SchemeMapImpl. " +
"Please file a issue to report this."
)
}
}
}
val prefix: String = builder.prefix
private var interpolatorList: List<QMUISchemeHandlerInterceptor> = builder.interceptorList
private val blockSameSchemeTimeout = builder.blockSameSchemeTimeout
val defaultIntentFactory = builder.defaultIntentFactory
val defaultFragmentFactory = builder.defaultFragmentFactory
val defaultSchemeMatcher = builder.defaultSchemeMatcherView on GitHub (pinned to 026e7d4866)
Solutions
- Add keep rules for the generated class: -keep class **.SchemeMapImpl { public <init>(); } (or keep com.qmuiteam.qmui.arch.scheme.**).
- Verify kapt/annotationProcessor (arch-compiler) is configured so SchemeMapImpl is actually generated at compile time.
- Check the generated SchemeMapImpl source (build/generated) and ensure the class and constructor are public.
- If the class exists, is public, and keep rules are present, report the issue to the QMUI Android repository as the message suggests.
Example fix
// before (proguard-rules.pro)
# no rule -> SchemeMapImpl stripped
// after
-keep class com.qmuiteam.qmui.arch.scheme.SchemeMapImpl { *; } Defensive patterns
Strategy: try-catch
Validate before calling
try {
Class.forName("com.qmuiteam.qmui.arch.scheme.SchemeMapImpl")
} catch (e: Throwable) {
Log.e(TAG, "SchemeMapImpl missing/inaccessible — check kapt + proguard rules", e)
} Type guard
fun isSchemeMapAvailable(): Boolean = runCatching {
Class.forName("com.qmuiteam.qmui.arch.scheme.SchemeMapImpl").constructors.any { it.parameterTypes.isEmpty() }
}.getOrDefault(false) Try / catch
val intent = try {
QMUISchemeHandler.instance.handle(uri)
} catch (e: RuntimeException) {
if (e.message?.contains("Can not access the Class SchemeMapImpl") == true) {
Log.e(TAG, "scheme init failed: keep rules / kapt missing", e)
null
} else throw e
} Prevention
- Add -keep rules for SchemeMapImpl and com.qmuiteam.qmui.arch.scheme.** in release builds
- Always apply arch-compiler via kapt/annotationProcessor in modules using @Scheme* annotations
- Smoke-test scheme handling in a minified release build, not only debug
- Keep arch and arch-compiler on the same version
When it happens
Trigger: First access to QMUISchemeHandler (its public init/companion) when annotation processing failed to generate SchemeMapImpl correctly, or the generated class/constructor is not public, or R8/ProGuard stripped or renamed SchemeMapImpl so reflection cannot access it.
Common situations: ProGuard/R8 keep-rule missing for com.qmuiteam.qmui.arch.scheme.SchemeMapImpl in a minified release build; annotation processor not applied so a stale/inaccessible generated class exists; multi-dex/classloader edge cases.
Related errors
- Can not access the Class RecordMetaMapImpl. Please file a is
- Can not instance the Class RecordMetaMapImpl. Please file a
- Can not instance the Class SchemeMapImpl. Please file a issu
- Error to get FragmentEffectHandler's generic parameter type
- no QMUIMediaPhotoProviderFactory is provided.
AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06).
Data as JSON: /api/errors/7e3316c5d1a52968.
Report an issue: GitHub.