Anuken/Mindustry · error · IllegalArgumentException
Not implemented on this platform!
Error message
Not implemented on this platform!
What it means
Platform is an interface describing host-specific behavior (file choosers, sharing, orientation). showFileChooser has a default implementation that throws IllegalArgumentException('Not implemented on this platform!') rather than being abstract, so the code compiles on every backend but only succeeds on one that overrides it. Each real backend (desktop, android, iOS) is expected to supply a working chooser. Hitting the default means the active Platform implementation is a stub or the headless/backend build.
Source
Thrown at core/src/mindustry/core/Platform.java:107
default String getUUID(){
String uuid = Core.settings.getString("uuid", "");
if(uuid.isEmpty()){
byte[] result = new byte[8];
new Rand().nextBytes(result);
uuid = new String(Base64Coder.encode(result));
Core.settings.put("uuid", uuid);
return uuid;
}
return uuid;
}
/** Only used for iOS: open the share menu for a map or save. */
default void shareFile(Fi file){
}
/** Do not call directly; use the builder pattern in {@link mindustry.ui.FileChooser}. */
default void showFileChooser(FileChooserParams params){
throw new IllegalArgumentException("Not implemented on this platform!");
}
/** Hide the app. Android only. */
default void hide(){
}
/** Forces the app into landscape mode.*/
default void beginForceLandscape(){
}
/** Stops forcing the app into landscape orientation.*/
default void endForceLandscape(){
}
interface FileWriter{
void write(Fi file) throws Throwable;
}
}View on GitHub (pinned to f695ad7e60)
Solutions
- Do not call showFileChooser on platforms that lack a UI; guard the call with a platform check (e.g. !headless / mobile / desktop) before opening the chooser.
- Prefer the FileChooser builder pattern in mindustry.ui.FileChooser over calling Platform.instance.showFileChooser directly.
- If you are implementing a custom backend, override showFileChooser in your Platform implementation.
- On headless/test code, inject a Platform stub that overrides showFileChooser or skip the UI code path entirely.
Example fix
// before
Platform.instance.showFileChooser(params);
// after
if(!Vars.headless){
Platform.instance.showFileChooser(params);
} Defensive patterns
Strategy: validation
Validate before calling
// only open a chooser on backends that support UI
if(!Vars.headless && (Vars.mobile || Vars.steam)){
Platform.instance.showFileChooser(params);
} Try / catch
try{ Platform.instance.showFileChooser(params); }catch(IllegalArgumentException e){ Log.err("No file chooser on this platform", e); } Prevention
- Gate all UI/dialog code behind a !headless check.
- Prefer the FileChooser builder over calling Platform.instance directly.
- When writing tests, inject a Platform stub that overrides showFileChooser.
- Document which backends implement each Platform method.
When it happens
Trigger: Invoking Platform.instance.showFileChooser(params) (or the FileChooser builder that routes to it) on a platform whose Platform impl does not override showFileChooser. Most commonly the headless server backend or a test/stub Platform. The recommended path is the FileChooser builder in mindustry.ui.FileChooser, not calling the interface directly.
Common situations: Running the headless server jar and triggering a code path that opens a file dialog; unit tests using a mock Platform that omits the override; a new/custom backend platform that wasn't given a chooser implementation.
Related errors
- Image is too large (maximum size is {MapResizeDialog.maxSize
- UI result entry count exceeds max entries:
- Too many long strings in MenuResult, reduce your amount of e
- Unknown UI entry type:
- Java class mods are not supported on iOS.
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/0f436e38932b4df1.
Report an issue: GitHub.