Tencent/QMUI_Android · critical · IllegalAccessError
the QMUISwipeBackActivityManager is not initialized; please
Error message
the QMUISwipeBackActivityManager is not initialized; please call QMUISwipeBackActivityManager.init(Application) in your application.
What it means
QMUISwipeBackActivityManager is a singleton that must be registered as an Application.ActivityLifecycleCallbacks via init(Application). getInstance() is @MainThread and throws IllegalAccessError when sInstance is null, i.e. when the swipe-back manager was never initialized, because activity tracking (needed for swipe-back gestures) cannot work without it.
Source
Thrown at arch/src/main/java/com/qmuiteam/qmui/arch/QMUISwipeBackActivityManager.java:38
import android.app.Application;
import android.os.Bundle;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Stack;
public class QMUISwipeBackActivityManager implements Application.ActivityLifecycleCallbacks {
private static QMUISwipeBackActivityManager sInstance;
private Stack<Activity> mActivityStack = new Stack<>();
private Activity mCurrentActivity = null;
@MainThread
public static QMUISwipeBackActivityManager getInstance() {
if (sInstance == null) {
throw new IllegalAccessError("the QMUISwipeBackActivityManager is not initialized; " +
"please call QMUISwipeBackActivityManager.init(Application) in your application.");
}
return sInstance;
}
private QMUISwipeBackActivityManager() {
}
public static void init(@NonNull Application application) {
if (sInstance == null) {
sInstance = new QMUISwipeBackActivityManager();
application.registerActivityLifecycleCallbacks(sInstance);
}
}
@Override
public void onActivityCreated(@NonNull Activity activity, Bundle savedInstanceState) {
if(mCurrentActivity == null){View on GitHub (pinned to 026e7d4866)
Solutions
- Call QMUISwipeBackActivityManager.init(this) inside your Application.onCreate().
- Verify AndroidManifest <application android:name=".MyApp"> points to the Application class that performs the init.
- Check init() is not gated behind a flag/build variant that skips it (e.g. only in debug).
- For non-UI code paths, avoid touching getInstance() before Application.onCreate completes.
Example fix
// before
public class MyApp extends Application {
@Override public void onCreate() {
super.onCreate();
}
}
// after
@Override public void onCreate() {
super.onCreate();
QMUISwipeBackActivityManager.init(this);
} Defensive patterns
Strategy: validation
Validate before calling
if (QMUISwipeBackActivityManager.getInstanceOrNull() == null) { // or guard in Application
QMUISwipeBackActivityManager.init(application);
} Try / catch
try {
QMUISwipeBackActivityManager.getInstance().someOp();
} catch (IllegalAccessError e) {
QMUISwipeBackActivityManager.init(application);
// retry once
} Prevention
- Call QMUISwipeBackActivityManager.init(this) first in Application.onCreate()
- Verify AndroidManifest android:name references your Application class
- Don't call swipe-back APIs from tests/ContentProviders before app init
When it happens
Trigger: Calling QMUISwipeBackActivityManager.getInstance() (or using QMUISwipeBackActivity / swipe-back features) before/without invoking QMUISwipeBackActivityManager.init(application) in your Application subclass; also occurs when the custom Application class is not registered in AndroidManifest.
Common situations: Forgetting init() when adding swipe-back to a project, AndroidManifest android:name not pointing at the Application class that performs init, or code paths (unit tests, content providers) running before Application.onCreate.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- Can not access the Class RecordMetaMapImpl. Please file a is
- Threshold value should be between 0 and 1.0
- Can not perform LatestVisitRecord, %s must be annotated by L
- Fragment(%s) not attached to Activity.
- Can not find the fragment container provider.
AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06).
Data as JSON: /api/errors/f8725c9e9ec49291.
Report an issue: GitHub.