asLody/VirtualApp · error · IllegalArgumentException
connection is null
Error message
connection is null
What it means
ServiceConnectionDelegate.getDelegate() wraps an app's ServiceConnection into an IServiceConnection binder stub. A null ServiceConnection cannot be dispatched to, so the method throws IllegalArgumentException before any binder work is attempted.
Solutions
- Always pass a real ServiceConnection instance when binding a service
- Construct the ServiceConnection before calling bindService, not inside its callback
- Null-check your connection variable at the call site
Example fix
// before
ServiceConnection conn = null; context.bindService(intent, conn, flags);
// after
ServiceConnection conn = new ServiceConnection() {
@Override public void onServiceConnected(ComponentName n, IBinder s) { }
@Override public void onServiceDisconnected(ComponentName n) { }
};
context.bindService(intent, conn, flags); Defensive patterns
Strategy: validation
Validate before calling
if (connection == null) throw new IllegalStateException("ServiceConnection must be created before bindService"); Try / catch
try { bindService(intent, conn, flags); } catch (IllegalArgumentException e) { Log.e(TAG, "null connection", e); } Prevention
- Create the ServiceConnection object before initiating the bind
- Avoid mutable connection fields set asynchronously
- Initialize connections in onCreate rather than lazily
When it happens
Trigger: Calling bindService (in the VA environment) with a null ServiceConnection parameter, which forwards null into getDelegate().
Common situations: Variable holding the connection not yet assigned (race with async init); caller mistakenly passing null to 'unbind-like' reuse of the helper; refactored code dropping the connection argument.
Related errors
- Initializer = NULL
- Not supported in system context
- accountType is null
- response is null
- accountType is null
AI-assisted analysis of asLody/VirtualApp@666fefcb5d (2026-09-09).
Data as JSON: /api/errors/2bb6ed62157fe5a0.
Report an issue: GitHub.
Appendix: source
Thrown at VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/secondary/ServiceConnectionDelegate.java:38
import mirror.android.app.IServiceConnectionO;
import mirror.android.app.LoadedApk;
/**
* @author Lody
*/
public class ServiceConnectionDelegate extends IServiceConnection.Stub {
private final static ArrayMap<IBinder, ServiceConnectionDelegate> DELEGATE_MAP = new ArrayMap<>();
private IServiceConnection mConn;
private ServiceConnectionDelegate(IServiceConnection mConn) {
this.mConn = mConn;
}
public static IServiceConnection getDelegate(Context context, ServiceConnection connection,int flags) {
IServiceConnection sd = null;
if (connection == null) {
throw new IllegalArgumentException("connection is null");
}
try {
Object activityThread = ActivityThread.currentActivityThread.call();
Object loadApk = ContextImpl.mPackageInfo.get(VirtualCore.get().getContext());
Handler handler = ActivityThread.getHandler.call(activityThread);
sd = LoadedApk.getServiceDispatcher.call(loadApk, connection, context, handler, flags);
} catch (Exception e) {
Log.e("ConnectionDelegate", "getServiceDispatcher", e);
}
if (sd == null) {
throw new RuntimeException("Not supported in system context");
}
return getDelegate(sd);
}
public static IServiceConnection removeDelegate(Context context, ServiceConnection conn) {
IServiceConnection connection = null;
try{View on GitHub (pinned to 666fefcb5d)