asLody/VirtualApp · error · IllegalArgumentException

accountType is null

Error message

accountType is null

What it means

VAccountManager.addAccount mirrors Android's AccountManager and requires a non-null accountType to identify the account authenticator. Passing null accountType throws IllegalArgumentException immediately before building the request Bundle.

Solutions

  1. Pass a non-empty account type string matching your Authenticator's accountType attribute
  2. Validate the type argument before calling addAccount
  3. If the type comes from an Account object, ensure the account was created with a valid type

Example fix

// before
am.addAccount(userId, null, null, null, options, activity, callback, handler);
// after
am.addAccount(userId, "com.example.myaccount", null, null, options, activity, callback, handler);
Defensive patterns

Strategy: validation

Validate before calling

if (accountType == null || accountType.isEmpty()) throw new IllegalArgumentException("accountType required before addAccount");

Type guard

String safeType(String t) { return (t == null || t.isEmpty()) ? DEFAULT_ACCOUNT_TYPE : t; }

Try / catch

try { am.addAccount(userId, type, ...); } catch (IllegalArgumentException e) { Log.e(TAG, "accountType missing", e); }

Prevention

When it happens

Trigger: Calling vAccountManager.addAccount(userId, null, ...) with a null accountType — e.g., the type string comes from a missing config, an Account whose type is null, or a refactor dropping the constant.

Common situations: Plugin authenticator metadata not parsed so type is null; hard-coded account type typo replaced by null default; upstream Account.getType() returning null for malformed accounts.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of asLody/VirtualApp@666fefcb5d (2026-09-09). Data as JSON: /api/errors/e0afce2abbfd2d09. Report an issue: GitHub.

Appendix: source

Thrown at VirtualApp/lib/src/main/java/com/lody/virtual/client/ipc/VAccountManager.java:261

            return VirtualRuntime.crash(e);
        }
    }

    /**
     * Asks the user to add an account of a specified type.  The authenticator
     * for this account type processes this request with the appropriate user
     * interface.  If the user does elect to create a new account, the account
     * name is returned.
     * <p>
     * <p>This method may be called from any thread, but the returned
     * {@link AccountManagerFuture} must not be used on the main thread.
     * <p>
     */
    public AccountManagerFuture<Bundle> addAccount(final int userId, final String accountType,
                                                   final String authTokenType, final String[] requiredFeatures,
                                                   final Bundle addAccountOptions,
                                                   final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
        if (accountType == null) throw new IllegalArgumentException("accountType is null");
        final Bundle optionsIn = new Bundle();
        if (addAccountOptions != null) {
            optionsIn.putAll(addAccountOptions);
        }
        optionsIn.putString(KEY_ANDROID_PACKAGE_NAME, "android");

        return new AmsTask(activity, handler, callback) {
            @Override
            public void doWork() throws RemoteException {
                addAccount(userId, mResponse, accountType, authTokenType,
                        requiredFeatures, activity != null, optionsIn);
            }
        }.start();
    }
}

View on GitHub (pinned to 666fefcb5d)