{"id":1339,"date":"2022-08-30T15:15:42","date_gmt":"2022-08-30T15:15:42","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/google-maps-ane-runtimeexception-attempting-to-create-multiple-datarequestdispatchers-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:42","modified_gmt":"2022-08-30T15:15:42","slug":"google-maps-ane-runtimeexception-attempting-to-create-multiple-datarequestdispatchers-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/google-maps-ane-runtimeexception-attempting-to-create-multiple-datarequestdispatchers-collection-of-common-programming-errors\/","title":{"rendered":"google maps ane: RuntimeException: Attempting to create multiple DataRequestDispatchers-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m creating a native extension that shows a native Google Map from a Flex-based AIR application. You can watch lee brimelow&#8217;s demo to get the idea: https:\/\/plus.google.com\/110495278155587072613\/posts\/degSYVx8423<\/p>\n<p>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&#8217;m getting on setContentView(layoutID):<\/p>\n<pre>\n    05-08 11:48:40.624: I\/System.out(27917): WebViewActivity.onCreate failed with error:\n    05-08 11:48:40.634: I\/System.out(27917): \"android.view.InflateException: Binary XML file line #9: Error inflating class fragment\"\n    05-08 11:48:40.644: W\/dalvikvm(27917): threadid=1: thread exiting with uncaught exception (group=0x40fd8468)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917): FATAL EXCEPTION: main\n    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\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.ActivityThread.access$600(ActivityThread.java:151)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.os.Handler.dispatchMessage(Handler.java:99)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.os.Looper.loop(Looper.java:155)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.ActivityThread.main(ActivityThread.java:5454)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at java.lang.reflect.Method.invokeNative(Native Method)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at java.lang.reflect.Method.invoke(Method.java:511)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at dalvik.system.NativeStart.main(Native Method)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917): Caused by: java.lang.RuntimeException: Attempting to create multiple DataRequestDispatchers\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.ak.n.b(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.ak.n.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.ak.h.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.af.w.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.z.ab.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.z.ab.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.z.ag.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.z.ag.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.z.bw.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at maps.z.r.onCreateView(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:107)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.os.Binder.transact(Binder.java:326)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.google.android.gms.maps.MapFragment$b.onCreateView(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.google.android.gms.internal.e$4.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.google.android.gms.internal.e.a(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.google.android.gms.internal.e.onCreateView(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at com.google.android.gms.maps.MapFragment.onCreateView(Unknown Source)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1037)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1019)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1804)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.Activity.performCreate(Activity.java:5069)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)\n    05-08 11:48:40.654: E\/AndroidRuntime(27917):    ... 11 more\n<\/pre>\n<p>I&#8217;m pretty convinced the communication between AIR and Android is ok, so I&#8217;m only posting my native code. (When I remove the map, the native extension works with no issues)<\/p>\n<p>Here is the layout xml file<\/p>\n<pre><code>\n\n        \n\n<\/code><\/pre>\n<p>Here is my FREFunction<\/p>\n<pre><code>public class GoogleMapsFunction implements FREFunction {\n\n@Override\npublic FREObject call(FREContext ctx, FREObject[] passedArgs) {\n    int layoutID, googleMapID;\n    Intent i = new Intent(ctx.getActivity(), WebViewActivity.class);\n\n    layoutID = ctx.getResourceId(\"layout.activity_google_maps\");\n    googleMapID = ctx.getResourceId(\"id.map\");\n\n    i.putExtra(\"layoutID\", layoutID);\n    i.putExtra(\"googleMapID\", googleMapID);\n\n    ctx.getActivity().startActivity(i);\n    return null;\n    }\n}\n<\/code><\/pre>\n<p>Here is my Activity<\/p>\n<pre><code>public class WebViewActivity extends Activity {\n    private GoogleMap map;\n\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n       super.onCreate(savedInstanceState);\n\n        try {\n            int layoutID = getIntent().getIntExtra(\"layoutID\", -1);\n            setContentView(layoutID);\n            int googleMapID = getIntent().getIntExtra(\"googleMapID\", -1);\n            map = ((MapFragment) getFragmentManager().findFragmentById(googleMapID))\n                    .getMap();\n        } catch(Exception e){\n            System.out.printf(\"WebViewActivity.onCreate failed with error:\\n\\\"%s\\\"\\n\",\n                      e.toString());\n            Toast.makeText(this, \"WebViewActivity.onCreate failed: \" +\n                   e.toString(), Toast.LENGTH_SHORT).show();            \n        }\n    }\n}\n<\/code><\/pre>\n<p>Here is my AndroidManifest<\/p>\n<pre><code>\n\n\n    \n\n    \n    \n\n    \n    \n\n    \n    \n    \n     \n    \n    \n    \n    \n\n\n    \n    \n    \n    \n    \n    \n\n    \n\n    \n        \n    \n\n\n<\/code><\/pre>\n<p>I see some com.google.android.gms. entries in the stacktrace, so I assume all google libraries are loaded correctly.<\/p>\n<p>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.<\/p>\n<p>Any idea&#8217;s?<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-10 00:45:05. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m creating a native extension that shows a native Google Map from a Flex-based AIR application. You can watch lee brimelow&#8217;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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1339","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1339"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1339\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}