package org.robolectric.internal.runtime;

import android.os.Build;

import org.robolectric.RuntimeEnvironment;

public class RuntimeAdapterFactory {
  public static RuntimeAdapter getInstance() {
    int apiLevel = RuntimeEnvironment.getApiLevel();
    if (apiLevel <= Build.VERSION_CODES.JELLY_BEAN) {
      return new Api16RuntimeAdapter();
    } else if (apiLevel <= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      return new Api17RuntimeAdapter();
    } else if (apiLevel <= Build.VERSION_CODES.KITKAT) {
      return new Api19RuntimeAdapter();
    } else if (apiLevel <= Build.VERSION_CODES.LOLLIPOP) {
      return new Api21RuntimeAdapter();
    } else {
      throw new RuntimeException("Could not find AndroidRuntimeAdapter for API level: " + apiLevel);
    }
  }
}

@@ -630,32 +630,135 @@
 ntimeAdapter();%0A
+    %7D else if (apiLevel %3C= Build.VERSION_CODES.LOLLIPOP_MR1) %7B%0A      return new Api22RuntimeAdapter();%0A
     %7D else %7B%0A   

Add RuntimeAdapter for API22. Attach has one new String parameter "referrer"