wasabeef/android-gpuimage · warning · IllegalStateException
Unknown Rotation!
Error message
Unknown Rotation!
What it means
Rotation.asInt() maps the four enum constants (NORMAL/ROTATION_90/ROTATION_180/ROTATION_270) to degrees; the default branch throws IllegalStateException("Unknown Rotation!"). This is a defensive branch for enum values outside the known set.
Solutions
- Update the switch in Rotation.asInt() to cover every declared enum constant.
- Align library versions — recompile/upgrade so the Rotation enum and its consumers match.
- Replace the default-throw with exhaustive handling (Java: no default throw; Kotlin: when expression without else to get compile-time exhaustiveness).
Example fix
// before
default:
throw new IllegalStateException("Unknown Rotation!");
// after
// make the switch exhaustive over all Rotation constants so the compiler catches missing cases
ROTATION_0 -> 0; ROTATION_90 -> 90; ROTATION_180 -> 180; ROTATION_270 -> 270; // no default throw Defensive patterns
Strategy: type-guard
Validate before calling
if (rotation == null) { /* handle null before asInt() */ } Type guard
boolean isKnownRotation(Rotation r) {
return r == Rotation.NORMAL || r == Rotation.ROTATION_90
|| r == Rotation.ROTATION_180 || r == Rotation.ROTATION_270;
} Try / catch
try {
int degrees = rotation.asInt();
} catch (IllegalStateException e) {
degrees = 0; // default to NORMAL on unknown rotation
} Prevention
- Keep enum switches exhaustive; prefer compile-time-checked when expressions in Kotlin
- Rebuild consumers when upgrading the library so enums stay in sync
- Avoid custom forked Rotation constants
When it happens
Trigger: Only reachable if a Rotation enum value exists that asInt() does not handle — e.g. adding a new enum constant (like a ROTATION_45) without updating asInt()'s switch, or reflection/obfuscation-produced mismatched enum state.
Common situations: Library/enum version skew where code compiled against a newer Rotation enum runs on an older switch; custom forks adding constants; R8/ProGuard changes are unlikely but non-exhaustive switches on enums are the root cause.
Related errors
- is an unknown rotation. Needs to be either 0, 90, 180 or…
- eglChooseConfig failed
- renderMode
- r must not be null
- setRenderer has already been called for this instance.
AI-assisted analysis of wasabeef/android-gpuimage@ceea576ec9 (2026-09-11).
Data as JSON: /api/errors/2b0dd54f65551953.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/jp/co/cyberagent/android/gpuimage/util/Rotation.java:38
NORMAL, ROTATION_90, ROTATION_180, ROTATION_270;
/**
* Retrieves the int representation of the Rotation.
*
* @return 0, 90, 180 or 270
*/
public int asInt() {
switch (this) {
case NORMAL:
return 0;
case ROTATION_90:
return 90;
case ROTATION_180:
return 180;
case ROTATION_270:
return 270;
default:
throw new IllegalStateException("Unknown Rotation!");
}
}
/**
* Create a Rotation from an integer. Needs to be either 0, 90, 180 or 270.
*
* @param rotation 0, 90, 180 or 270
* @return Rotation object
*/
public static Rotation fromInt(int rotation) {
switch (rotation) {
case 0:
return NORMAL;
case 90:
return ROTATION_90;
case 180:
return ROTATION_180;
case 270:View on GitHub (pinned to ceea576ec9)