I have a question about using GWT-RequestFactory in Android. As a starting point, I used the code from "Create a AppEngine connected Android-Project" -Wizard (info: http://code.google.com/intl/de-DE/eclipse/docs/appengine_connected_android.html ) and it worked big.
But now in my case, I want to expand this application to use the local ContentProvider with SQLite, and SyncService with SyncAdapter - to synchronize data from ContentProvider with AppEngine using RequestFactory. Now my problem is this: I can call
MyRequestFactory requestFactory = Util.getRequestFactory(mContext, MyRequestFactory.class);
in any operation I want and will receive an instance of MyRequestFactory. (Note: Util is a class created by the wizard.) But if I try to make the same call from my SyncAdapter, I get java.lang.RuntimeException: RequestFactory ValidationTool must be run for com.hotool.client.MyRequestFactory RequestFactory type ".
Perhaps for your information: the Util.getRequestFacory method looks like this:
public static <T extends RequestFactory> T getRequestFactory( Context context, Class<T> factoryClass) { T requestFactory = RequestFactorySource.create(factoryClass); SharedPreferences prefs = getSharedPreferences(context); String authCookie = prefs.getString(Util.AUTH_COOKIE, null); String uriString = Util.getBaseUrl(context) + RF_METHOD; URI uri; try { uri = new URI(uriString); } catch (URISyntaxException e) { Log.w(TAG, "Bad URI: " + uriString, e); return null; } requestFactory.initialize(new SimpleEventBus(), new AndroidRequestTransport(uri, authCookie)); return requestFactory; }
The error occurs in RequestFactorySource , which is located in requestfactory-client.jar. I think this may be a Class-Loader problem, but tried to figure it out without success.
I tried using ValidationTool, but it didnโt help in the first place, and secondly, I found that the classes created by ValidationTool already exist (possibly due to annotation processing, as indicated here: http://code.google.com / p / google-web-toolkit / wiki / RequestFactoryInterfaceValidation )
Does anyone have any ideas what might cause this?
Many thanks and best wishes.
Marcus Neuenschwander