resources/src/main/java/org/robolectric/res/android/NativeObjRegistry.java
public synchronized T unregister(long nativeId) {
    T o = nativeObjToIdMap.remove(nativeId);
    if (debug) {
      System.out.printf("NativeObjRegistry %s: unregister %d -> %s%n", name, nativeId, o);
      new RuntimeException("unregister debug").printStackTrace(System.out);
    }
    if (o == null) {
      if (debug) {
        DebugInfo debugInfo = idToDebugInfoMap.get(nativeId);
        debugInfo.unregistrationTraces.add(new Trace(o));
        if (debugInfo.unregistrationTraces.size() > 1) {
          System.out.format("NativeObjRegistry %s: Too many unregistrations:%n", name);
          for (Trace unregistration : debugInfo.unregistrationTraces) {
            unregistration.printStackTrace(System.out);
          }
        }
      }
      throw new IllegalStateException(
          nativeId + " has already been removed (or was never registered)");
    }
    return o;
  }
public synchronized T unregister(long nativeId) {
    T o = nativeObjToIdMap.remove(nativeId);
    if (debug) {
      System.out.printf("NativeObjRegistry %s: unregister %d -> %s%n", name, nativeId, o);
      new RuntimeException("unregister debug").printStackTrace(System.out);
    }
    if (o == null) {
      if (debug) {
        DebugInfo debugInfo = idToDebugInfoMap.get(nativeId);
        debugInfo.unregistrationTraces.add(new Trace(o));
        if (debugInfo.unregistrationTraces.size() > 1) {
          System.out.format("NativeObjRegistry %s: Too many unregistrations:%n", name);
          for (Trace unregistration : debugInfo.unregistrationTraces) {
            unregistration.printStackTrace(System.out);
          }
        }
      }
      throw new IllegalStateException(
          nativeId + " has already been removed (or was never registered)");
    }
    return o;
  }
public synchronized T unregister ( long nativeId ) { T o = nativeObjToIdMap . remove ( nativeId ) ; if ( debug ) { System . out . printf ( "NativeObjRegistry %s: unregister %d -> %s%n" , name , nativeId , o ) ; new RuntimeException ( "unregister debug" ) . printStackTrace ( System . out ) ; } if ( o == null ) { if ( debug ) { DebugInfo debugInfo = idToDebugInfoMap . get ( nativeId ) ; debugInfo . unregistrationTraces . add ( new Trace ( o ) ) ; if ( debugInfo . unregistrationTraces . size ( ) > 1 ) { System . out . format ( "NativeObjRegistry %s: Too many unregistrations:%n" , name ) ; for ( Trace unregistration : debugInfo . unregistrationTraces ) { unregistration . printStackTrace ( System . out ) ; } } } throw new IllegalStateException ( nativeId + " has already been removed (or was never registered)" ) ; } return o ; }
Unregister an object previously registered with {@link #register(Object)}.

@param nativeId the unique id (representing a C memory pointer) of the object to unregister.
@throws IllegalStateException if the object was never registered, or was previously
unregistered.
Unregister an object previously registered with { @link #register ( Object ) } .