asLody/VirtualApp · error · java.lang.IllegalArgumentException
account is null
Error message
account is null
What it means
getPreviousName(userId, account) throws IllegalArgumentException('account is null') as a fail-fast guard when the caller passes a null Account. VirtualApp's VAccountManagerService mirrors Android's AccountManager contract, which requires a non-null account to look up the previous name. The throw happens before any account lookup or locking.
Solutions
- Ensure the Account passed to getPreviousName is non-null before calling (check for null and skip/return)
- Verify the code that produced the Account (getAccounts / getAccountsByTypeAndFeatures callback) and handle empty results instead of propagating null
- Catch IllegalArgumentException around the call as a last resort and treat it as 'no previous name'
Example fix
// before
String prev = manager.getPreviousName(userId, account);
// after
if (account != null) {
String prev = manager.getPreviousName(userId, account);
} else {
String prev = null; // handle missing account
} Defensive patterns
Strategy: validation
Validate before calling
if (account == null) { throw new IllegalStateException("Cannot getPreviousName: account is null"); } Type guard
boolean isValidAccount(Account a) { return a != null && a.type != null && a.name != null; } Prevention
- Null-check accounts returned from AccountManager lookups before use
- Never cache Account references across sign-out flows without re-validating
- Treat null account as 'no data' in UI/reporting layers rather than passing it down
When it happens
Trigger: Calling getPreviousName with a null Account object, typically because an earlier AccountManager call (e.g. getAccounts, getAccountsByTypeAndFeatures) returned an array/entry the caller assumed was non-null, or a variable holding the account was never initialized.
Common situations: App code iterating accounts from a callback that can deliver empty/null results; refactors where an Account field is assigned null on failure; testing code that calls the service directly without constructing an Account.
Related errors
AI-assisted analysis of asLody/VirtualApp@666fefcb5d (2026-09-09).
Data as JSON: /api/errors/a64f0e0f41298f19.
Report an issue: GitHub.
Appendix: source
Thrown at VirtualApp/lib/src/main/java/com/lody/virtual/server/accounts/VAccountManagerService.java:154
return;
}
if (features == null || features.length == 0) {
Bundle bundle = new Bundle();
bundle.putParcelableArray(AccountManager.KEY_ACCOUNTS, getAccounts(userId, type));
try {
response.onResult(bundle);
} catch (RemoteException e) {
e.printStackTrace();
}
} else {
new GetAccountsByTypeAndFeatureSession(response, userId, info, features).bind();
}
}
@Override
public final String getPreviousName(int userId, Account account) {
if (account == null) throw new IllegalArgumentException("account is null");
synchronized (accountsByUserId) {
String previousName = null;
VAccount vAccount = getAccount(userId, account);
if (vAccount != null) {
previousName = vAccount.previousName;
}
return previousName;
}
}
@Override
public Account[] getAccounts(int userId, String type) {
List<Account> accountList = getAccountList(userId, type);
return accountList.toArray(new Account[accountList.size()]);
}
View on GitHub (pinned to 666fefcb5d)