google maps ane: RuntimeException: Attempting to create multiple DataRequestDispatchers-Collection of common programming errors
I’m creating a native extension that shows a native Google Map from a Flex-based AIR application. You can watch lee brimelow’s demo to get the idea: https://plus.google.com/110495278155587072613/posts/degSYVx8423
I got a working demo of a native extension, just to show an Activity with some buttons, but I got stuck when I tried to show the map. Here is the exception I’m getting on setContentView(layoutID):
05-08 11:48:40.624: I/System.out(27917): WebViewActivity.onCreate failed with error: 05-08 11:48:40.634: I/System.out(27917): "android.view.InflateException: Binary XML file line #9: Error inflating class fragment" 05-08 11:48:40.644: W/dalvikvm(27917): threadid=1: thread exiting with uncaught exception (group=0x40fd8468) 05-08 11:48:40.654: E/AndroidRuntime(27917): FATAL EXCEPTION: main 05-08 11:48:40.654: E/AndroidRuntime(27917): java.lang.RuntimeException: Unable to start activity ComponentInfo{air.GoogleMapsApp.debug/com.trasys.googlemaps.WebViewActivity}: java.lang.RuntimeException: Attempting to create multiple DataRequestDispatchers 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.access$600(ActivityThread.java:151) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Handler.dispatchMessage(Handler.java:99) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Looper.loop(Looper.java:155) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.main(ActivityThread.java:5454) 05-08 11:48:40.654: E/AndroidRuntime(27917): at java.lang.reflect.Method.invokeNative(Native Method) 05-08 11:48:40.654: E/AndroidRuntime(27917): at java.lang.reflect.Method.invoke(Method.java:511) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796) 05-08 11:48:40.654: E/AndroidRuntime(27917): at dalvik.system.NativeStart.main(Native Method) 05-08 11:48:40.654: E/AndroidRuntime(27917): Caused by: java.lang.RuntimeException: Attempting to create multiple DataRequestDispatchers 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.n.b(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.n.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.ak.h.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.af.w.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ab.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ab.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ag.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.ag.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.bw.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at maps.z.r.onCreateView(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:107) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.os.Binder.transact(Binder.java:326) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.MapFragment$b.onCreateView(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e$4.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e.a(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.internal.e.onCreateView(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at com.google.android.gms.maps.MapFragment.onCreateView(Unknown Source) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1037) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1019) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1804) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.Activity.performCreate(Activity.java:5069) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101) 05-08 11:48:40.654: E/AndroidRuntime(27917): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 05-08 11:48:40.654: E/AndroidRuntime(27917): ... 11 more
I’m pretty convinced the communication between AIR and Android is ok, so I’m only posting my native code. (When I remove the map, the native extension works with no issues)
Here is the layout xml file
Here is my FREFunction
public class GoogleMapsFunction implements FREFunction {
@Override
public FREObject call(FREContext ctx, FREObject[] passedArgs) {
int layoutID, googleMapID;
Intent i = new Intent(ctx.getActivity(), WebViewActivity.class);
layoutID = ctx.getResourceId("layout.activity_google_maps");
googleMapID = ctx.getResourceId("id.map");
i.putExtra("layoutID", layoutID);
i.putExtra("googleMapID", googleMapID);
ctx.getActivity().startActivity(i);
return null;
}
}
Here is my Activity
public class WebViewActivity extends Activity {
private GoogleMap map;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
int layoutID = getIntent().getIntExtra("layoutID", -1);
setContentView(layoutID);
int googleMapID = getIntent().getIntExtra("googleMapID", -1);
map = ((MapFragment) getFragmentManager().findFragmentById(googleMapID))
.getMap();
} catch(Exception e){
System.out.printf("WebViewActivity.onCreate failed with error:\n\"%s\"\n",
e.toString());
Toast.makeText(this, "WebViewActivity.onCreate failed: " +
e.toString(), Toast.LENGTH_SHORT).show();
}
}
}
Here is my AndroidManifest
I see some com.google.android.gms. entries in the stacktrace, so I assume all google libraries are loaded correctly.
I created a separate pure native android application for testing purpose. In this app I managed to create an activity which displays the map, this activity uses the same layout XML, the same google libraries and the same API key.
Any idea’s?
Originally posted 2013-11-10 00:45:05.