Search code examples
androidrequestfactoryandroid-maps-v2

RequestFactory validation fails when including Android maps v2 fragment


I have successfully used RequestFactory for a very long time in my Android app, but now when trying to upgrade to maps v2, when I include

<fragment
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />

in my XML layout file, I get the error:

01-25 08:08:41.978: E/AndroidRuntime(19854):
java.lang.RuntimeException: Unable to resume activity{com.xx/com.xx.MyActivity}:
java.lang.RuntimeException: The RequestFactory ValidationTool must be
run for the com.xx.client.MyRequestFactory RequestFactory type

If I remove the fragment code from the layout XML file everything works fine.

How does this fragment affect my RequestFactory validation and how can I fix it?

Thanks.


Solution

  • As pointed out in How to Use the GWT-RequestFactory in Android SyncAdapter (always getting ValidationTool-Error)

    if one adds

    Thread.currentThread().setContextClassLoader(mContext.getClassLoader());
    

    before

    requestFactory = RequestFactorySource.create(factoryClass);
    

    the problem is fixed.