MuntashirAkon/AppManager · error · IOException
Token is not found.
Error message
Token is not found.
What it means
ServerHandler builds its runtime configuration from mConfigParams: it parses the listen port from the config path and then requires the authentication token. If mConfigParams.getToken() returns null it throws IOException('Token is not found.') because the Server cannot authenticate any client without a shared token. This is a missing-required-configuration guard at server startup.
Source
Thrown at server/src/main/java/io/github/muntashirakon/AppManager/server/ServerHandler.java:53
private final Server mServer;
private final boolean mRunInBackground;
private Handler mHandler;
private volatile boolean mIsDead = false;
ServerHandler(@NonNull LifecycleAgent lifecycleAgent) throws IOException {
mLifecycleAgent = lifecycleAgent;
mConfigParams = mLifecycleAgent.getConfigParams();
// Set params
System.out.println("Config params: " + mConfigParams);
int port;
try {
port = Integer.parseInt(mConfigParams.getPath());
} catch (Exception e) {
throw new IOException(e);
}
String token = mConfigParams.getToken();
if (token == null) throw new IOException("Token is not found.");
mRunInBackground = mConfigParams.isRunInBackground();
mServer = new Server(port, token, mLifecycleAgent, this);
mServer.mRunInBackground = mRunInBackground;
// If run in background not requested, stop server on timeout
if (!mRunInBackground) {
HandlerThread handlerThread = new HandlerThread("am_server_watcher");
handlerThread.start();
mHandler = new Handler(handlerThread.getLooper()) {
@Override
public void handleMessage(@NonNull Message message) {
super.handleMessage(message);
if (message.what == MSG_TIMEOUT) {
close();
}
}
};
mHandler.sendEmptyMessageDelayed(MSG_TIMEOUT, DEFAULT_TIMEOUT);
}View on GitHub (pinned to 0152f468fc)
Solutions
- Pass the token when starting the server: use AppManager's own launch path (which generates and embeds the token) rather than a hand-written command.
- If launching manually, inspect how mConfigParams is parsed (path = port, token param) and supply both correctly in the expected format.
- Regenerate/re-run the server starter from the current AppManager build so the argument layout matches this code version.
- Add a startup check in your launcher script that aborts with a clear message when the token argument is empty.
Example fix
// before: manual launch missing token am_server 7899 // after: supply token in the expected config format (via AppManager's generated invocation) am_server <config-with-port-and-token> // or in code: config.setToken(token); // ensure non-null before new ServerHandler(config)
Defensive patterns
Strategy: validation
Validate before calling
String token = mConfigParams.getToken();
if (token == null || token.isEmpty()) {
throw new IllegalArgumentException("Server launch requires a token; regenerate via AppManager's server starter.");
}
int port = Integer.parseInt(mConfigParams.getPath()); // also guard NumberFormatException
Try / catch
try {
new ServerHandler(configParams).start();
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().contains("Token is not found")) {
// regenerate config with a fresh token and relaunch
}
}
Prevention
- Always start the server via AppManager's generated invocation, never a hand-rolled command line.
- Validate config (port parses, token non-null) before constructing ServerHandler.
- Keep launcher scripts in sync with the AppManager version's expected argument layout.
- Fail fast in wrappers: abort launch scripts when the token argument is empty.
When it happens
Trigger: Launching the AM server (am_server) without supplying the token as a config parameter — i.e. the invocation omits the token argument/component, the config Uri carries no token extra/query, or the caller constructing ServerHandler passed a params object with null token.
Common situations: Manually running the server binary on the command line and forgetting the token argument; stale launcher script from an older AppManager version with different argument layout; programmatic integration constructing ServerHandler config without setting the token; shell expansion dropping an argument.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- The app has keystore items and KeyStore backup isn't enabled
- Unsupported mode ${mParentMode}
- Invalid App Manager version
- Block size must be a multiple of 512 bytes. Attempt to use s
- blockSize(" + blockSize + ") < 1
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/29f3338f5d2a5183.
Report an issue: GitHub.