Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13864] Android: Maps v2 crashes inside a tab

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2014-03-20T23:09:00.000+0000
Affected Version/sn/a
Fix Version/s2014 Sprint 06, 2014 Sprint 06 SDK, Release 3.2.3, Release 3.3.0
ComponentsAndroid
Labelsmodule_androidmapv2, qe-closed-3.2.3, qe-testadded, supportTeam, triage
ReporterRomain Salles
AssigneeHieu Pham
Created2013-05-15T11:23:15.000+0000
Updated2014-07-11T23:06:18.000+0000

Description

Problem

Google Maps Android API v2 are not compatible with the Holo theme. We have experienced the same problem in our app : when Holo is not active, the maps work as expected. With Holo, the app crash. There are the error logs :
05-15 10:33:55.700: E/TiApplication(25966): (main) [9931,10138] Sending event: exception on thread: main msg:java.lang.IllegalArgumentException: No view found for id 0x3e8 for fragment SupportMapFragment{436e6020 #0 id=0x3e8}; Titanium 3.1.0006,2013/05/06 12:00,2b7add3
05-15 10:33:55.700: E/TiApplication(25966): java.lang.IllegalArgumentException: No view found for id 0x3e8 for fragment SupportMapFragment{436e6020 #0 id=0x3e8}
05-15 10:33:55.700: E/TiApplication(25966): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:865)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.os.Handler.handleCallback(Handler.java:605)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.os.Handler.dispatchMessage(Handler.java:92)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.os.Looper.loop(Looper.java:137)
05-15 10:33:55.700: E/TiApplication(25966): 	at android.app.ActivityThread.main(ActivityThread.java:4507)
05-15 10:33:55.700: E/TiApplication(25966): 	at java.lang.reflect.Method.invokeNative(Native Method)
05-15 10:33:55.700: E/TiApplication(25966): 	at java.lang.reflect.Method.invoke(Method.java:511)
05-15 10:33:55.700: E/TiApplication(25966): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
05-15 10:33:55.700: E/TiApplication(25966): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
05-15 10:33:55.700: E/TiApplication(25966): 	at dalvik.system.NativeStart.main(Native Method)
05-15 10:33:55.705: E/AndroidRuntime(25966): FATAL EXCEPTION: main
I have minimised his code to reproduce the error. There is the code for *app.js* :
(function() {
	function ApplicationWindow(title) {
	    var self = Ti.UI.createWindow({ title:title });
	  
	    self.activity.onCreateOptionsMenu = function (e) {
	        var actionBar = self.activity.actionBar;
	        actionBar.setTitle('Action bar');
	        actionBar.displayHomeAsUp = true;
	        actionBar.onHomeIconItemSelected = function () {};
	    };
	
	    if (title === 'Map') {   
	        var MapModule = require('ti.map');
	        var mapview = MapModule.createView({
	            region: {latitude:33.74511, longitude:-84.38993,
	                    latitudeDelta:0.01, longitudeDelta:0.01}
	        });
	
	        self.add(mapview);
	    }
	
	    return self;
	};


    var tabGroup = Ti.UI.createTabGroup();
	var tabs = ['One', 'Two', 'Map'];
	for (var i=0, l=tabs.length; i<l; i+=1) {
		var win = new ApplicationWindow(tabs[i]),
		    tab = Ti.UI.createTab({title: tabs[i], window: win});

		tabGroup.addTab(tab);
	}

	tabGroup.open();
})();
And there is the *tiapp.xml* file :
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.enera.tabbedmap</id>
    <name>Test</name>
    <version>1.0</version>
    <publisher>romainsalles</publisher>
    <url>http://</url>
    <description>not specified</description>
    <copyright>foo</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>false</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid>22bd9dd2-b7a9-482b-9b64-e21eb739d636</guid>
    <property name="ti.ui.defaultunit" type="string">system</property>
    <iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14"/>
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
            <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
            <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
            <uses-permission android:name="com.enera.tabbedmap.permission.MAPS_RECEIVE"/>
            <permission android:name="com.enera.tabbedmap.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
            <application android:theme="@android:style/Theme.Holo">
                <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyDYBIo7m2GkNpiwQ2VpwfH_FwOtm8a_V-w"/>
            </application>
        </manifest>
    </android>
    <mobileweb>
        <precache/>
        <splash>
            <enabled>true</enabled>
            <inline-css-images>true</inline-css-images>
        </splash>
        <theme>default</theme>
    </mobileweb>
    <modules>
    	<module platform="android">ti.map</module>	
    </modules>
    <deployment-targets>
        <target device="blackberry">false</target>
        <target device="android">true</target>
        <target device="ipad">true</target>
        <target device="iphone">true</target>
        <target device="mobileweb">true</target>
        <target device="tizen">false</target>
    </deployment-targets>
    <sdk-version>3.1.0.GA</sdk-version>
</ti:app>
When the app opens, just click on the *Map tab* and it will crash on devices with Holo. We have tested on : - Samsung Galaxy Ace (GT-S5830), android 2.3.3 -> *ok* (do not supports Holo) - Sony Xperia (LT15i), android 2.3.3 -> *ok* (do not supports Holo) - Samsung Galaxy S (GTI9000), android 2.3.3 -> *ok* (do not supports Holo) - Samsung S2 (GT-I9100P), android 4.0.3 -> *crash* (supports Holo) - Nexus S, android 4.1.2 -> *crash* (supports Holo) - Samsung S3 (GT-I93000), android 4.1.2 -> *crash* (supports Holo) It's really annoying : we have worked a lot to make our app more android friendly (holo, maps v2, GCM, new UX ...) and *we can't publish* it because of this problem.

Associated Q&A thread

http://developer.appcelerator.com/question/151567/google-maps-v2-module-crashes-when-view-placed-in-tab-group#comment-172642

Comments

  1. Romain Salles 2013-05-17

    Any news on this ?
  2. Romain Salles 2013-05-28

    A point which could help : we have found a hack to make the maps work with Holo. The trick is to add the mapview on the window focus. In my code example, you have to change this line :
       self.add(mapview);
       
    by these ones :
       self.addEventListener('focus', function() {
       	self.add(mapview);
       });
       
    I hope it helps to solve the issue.
  3. luca capra 2013-09-02

    the hack is not working for me. Map in tabgroup always crash the app.
  4. Hans Knöchel 2013-10-16

    Still having problems here. Holo-Theme + Ti.Maps-Module crashes the app: E/TiApplication(21096): java.lang.IllegalArgumentException: No view found for id 0x3e8 for fragment SupportMapFragment{414b1710 #0 id=0x3e8} E/TiApplication(21096): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:865) E/TiApplication(21096): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083) E/TiApplication(21096): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635) E/TiApplication(21096): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431) E/TiApplication(21096): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
  5. Eduardo Gomez 2014-01-21

    Tested and reproduced the bug with 3.2.0.GA, Android 4.0.4 and ti.map 2.1.2. Work around suggested by [~romain.salles] worked for me. [~hansknoechel], did you try this suggestion?
       			var MapModule = require('ti.map');
       			var mapview = MapModule.createView({
       				region : {
       					latitude : 33.74511,
       					longitude : -84.38993,
       					latitudeDelta : 0.01,
       					longitudeDelta : 0.01
       				}
       			});
       
       			//self.add(mapview);
       			self.addEventListener('focus', function() {
       				self.add(mapview);
       			});
       
  6. Bitfabrikken - Dan Wulff Kronholm 2014-01-25

    I have the same issue as well on 3.2.0.GA, Android 4.0.4 and ti.map 2.1.2. Only way I can get the map to show, is if I create a brand new window and add it to that using the focus hack above. Here's the crash output from my Nexus 5:
       
       [INFO]  I/Adreno-EGL: <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
       [DEBUG] OpenGLRenderer: Enabling debug mode 0
       [DEBUG] dalvikvm: GC_CONCURRENT freed 339K, 2% free 25392K/25748K, paused 2ms+3ms, total 21ms
       [TRACE] CustomViewBehind: behind INVISIBLE
       [WARN]  dalvikvm: VFY: unable to resolve static field 930 (MapAttrs) in Lcom/google/android/gms/R$styleable;
       [DEBUG] dalvikvm: VFY: replacing opcode 0x62 at 0x000e
       [DEBUG] AndroidRuntime: Shutting down VM
       [WARN]  dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x415deba8)
       [ERROR] TiApplication: (main) [626,939] Sending event: exception on thread: main msg:java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState; Titanium 3.2.0,2013/12/20 10:57,d9182d6
       [ERROR] TiApplication: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       [ERROR] TiApplication:  at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1314)
       [ERROR] TiApplication:  at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1325)
       [ERROR] TiApplication:  at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:548)
       [ERROR] TiApplication:  at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:532)
       [ERROR] TiApplication:  at org.appcelerator.titanium.view.TiUIFragment.<init>(TiUIFragment.java:41)
       [ERROR] TiApplication:  at ti.map.TiUIMapView.<init>(TiUIMapView.java:55)
       [ERROR] TiApplication:  at ti.map.ViewProxy.createView(ViewProxy.java:63)
       [ERROR] TiApplication:  at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:465)
       [ERROR] TiApplication:  at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:451)
       [ERROR] TiApplication:  at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:568)
       [ERROR] TiApplication:  at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:220)
       [ERROR] TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:98)
       [ERROR] TiApplication:  at android.os.Looper.loop(Looper.java:136)
       [ERROR] TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:5017)
       [ERROR] TiApplication:  at java.lang.reflect.Method.invokeNative(Native Method)
       [ERROR] TiApplication:  at java.lang.reflect.Method.invoke(Method.java:515)
       [ERROR] TiApplication:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
       [ERROR] TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
       [ERROR] TiApplication:  at dalvik.system.NativeStart.main(Native Method)
       
       
  7. Hieu Pham 2014-03-12

    master PR: https://github.com/appcelerator/titanium_mobile/pull/5462
  8. Hieu Pham 2014-03-20

    3.2.x PR: https://github.com/appcelerator/titanium_mobile/pull/5499
  9. Neha Mittal 2014-03-24

    Verified fix using below environment: Appc Studio: 3.2.3.201403190645 Sdk: 3.2.3.v20140323211726 acs: 1.0.14 npm: 1.3.2 alloy:1.3.1 titanium:3.2.1 titanium-code-processor:1.1.0 Xcode: 5.1 Osx: Maverick(10.9.2) Device: Nexus 7 (V 4.4.2) Android: Maps v2 does not crashes inside Tab.
  10. Mark Mokryn 2014-05-01

JSON Source