microg/GmsCore · error · IllegalArgumentException

Could not access the field in remoteBinder.

Error message

Could not access the field in remoteBinder.

What it means

During ObjectWrapper.unwrap, field.get(binder) threw an IllegalAccessException, rethrown as 'Could not access the field in remoteBinder.' Reflection was denied access to the wrapper's field — the field is not accessible and setAccessible/visibility rules (or JVM/module restrictions) blocked the read.

Source

Thrown at play-services-basement/src/main/java/com/google/android/gms/dynamic/ObjectWrapper.java:82

            }
        }

        if (field == null) {
            throw new IllegalArgumentException("No non-synthetic fields were found");
        }

        if (!field.isAccessible()) {
            field.setAccessible(true);
            try {
                return field.get(binder);
            } catch (NullPointerException localNullPointerException) {
                throw new IllegalArgumentException("Binder object is null.",
                        localNullPointerException);
            } catch (IllegalArgumentException localIllegalArgumentException) {
                throw new IllegalArgumentException("remoteBinder is the wrong class.",
                        localIllegalArgumentException);
            } catch (IllegalAccessException localIllegalAccessException) {
                throw new IllegalArgumentException("Could not access the field in remoteBinder.",
                        localIllegalAccessException);
            }
        } else {
            throw new IllegalArgumentException();
        }
    }

    @Nullable
    public static <T> T unwrapTyped(IObjectWrapper obj, Class<T> clazz) {
        try {
            return clazz.cast(unwrap(obj));
        } catch (ClassCastException e) {
            return null;
        }
    }

    public static <T> ObjectWrapper<T> wrap(T t) {
        return new ObjectWrapper<T>(t);

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Keep com.google.android.gms.dynamic.** classes and members (including non-public ones) via proguard keep rules
  2. Ensure the binder class is loaded by the app's classloader, not an isolated one
  3. Catch IllegalArgumentException and handle gracefully instead of crashing
  4. If feasible, pass the wrapped value through a typed AIDL interface instead of reflective unwrap

Example fix

// before
Object v = ObjectWrapper.unwrap(w); // IllegalAccessException path
// after
Object v;
try {
    v = ObjectWrapper.unwrap(w);
} catch (IllegalArgumentException e) {
    Log.w(TAG, "Cannot unwrap remote binder", e);
    v = null;
}
Defensive patterns

Strategy: try-catch

Validate before calling

IBinder b = wrapper.asBinder();
if (b == null || !b.getClass().getName().startsWith("com.google.android.gms.dynamic")) {
    /* foreign/restricted binder — avoid reflective unwrap */
}

Try / catch

try {
    T value = ObjectWrapper.unwrapTyped(wrapper, T.class);
} catch (IllegalArgumentException e) {
    // includes IllegalAccessException path — fall back to non-reflective access
}

Prevention

When it happens

Trigger: The binder class or its field was made non-public/inaccessible (obfuscation, custom classloader, restricted module); running on a JVM/Android version where setAccessible on that member is disallowed; a custom IObjectWrapper implementation with a private field in a restricted package.

Common situations: Aggressive proguard/R8 configs altering visibility of gms dynamic classes; instrumentation or sandboxed environments blocking reflection; mismatched classloaders in plugin/dynamic-feature setups.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/cdda2d5c752de2e4. Report an issue: GitHub.