Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2217] Android: Random Crashes on Google Maps v2 API

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-01-17T07:24:49.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, map, mapview
ReporterYgor Lemos
AssigneeRitu Agrawal
Created2013-08-29T15:30:06.000+0000
Updated2016-03-08T07:41:12.000+0000

Description

Sometimes when I open a MapView with Annotation I get this Random Crash. Several Beta Testers using several different devices have reported the same error and I have received the reports through Google Play of this crash related to the new ti.map android API (GMaps v2)
08-29 12:21:11.839: D/AndroidRuntime(28397): Shutting down VM
08-29 12:21:11.839: W/dalvikvm(28397): threadid=1: thread exiting with uncaught exception (group=0x414f0700)
08-29 12:21:11.839: E/TiApplication(28397): (main) [82734,82863] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.1.2,2013/08/14 12:46,5ceaff8
08-29 12:21:11.839: E/TiApplication(28397): java.lang.NullPointerException
08-29 12:21:11.839: E/TiApplication(28397): 	at android.view.ViewConfiguration.get(ViewConfiguration.java:318)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.view.View.<init>(View.java:3264)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.view.View.<init>(View.java:3315)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.widget.TextView.<init>(TextView.java:619)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.widget.TextView.<init>(TextView.java:614)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.widget.TextView.<init>(TextView.java:610)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.modules.titanium.ui.widget.TiUILabel$1.<init>(TiUILabel.java:40)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.modules.titanium.ui.widget.TiUILabel.<init>(TiUILabel.java:39)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.modules.titanium.ui.LabelProxy.createView(LabelProxy.java:55)
08-29 12:21:11.839: E/TiApplication(28397): 	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:452)
08-29 12:21:11.839: E/TiApplication(28397): 	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:438)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.map.TiMapInfoWindow.setLeftOrRightPane(TiMapInfoWindow.java:179)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.map.AnnotationProxy.processOptions(AnnotationProxy.java:162)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.map.TiUIMapView.addAnnotation(TiUIMapView.java:268)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.map.TiUIMapView.processPreloadAnnotations(TiUIMapView.java:71)
08-29 12:21:11.839: E/TiApplication(28397): 	at ti.map.TiUIMapView.onViewCreated(TiUIMapView.java:87)
08-29 12:21:11.839: E/TiApplication(28397): 	at org.appcelerator.titanium.view.TiUIFragment.handleMessage(TiUIFragment.java:58)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.os.Handler.dispatchMessage(Handler.java:95)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.os.Looper.loop(Looper.java:137)
08-29 12:21:11.839: E/TiApplication(28397): 	at android.app.ActivityThread.main(ActivityThread.java:5103)
08-29 12:21:11.839: E/TiApplication(28397): 	at java.lang.reflect.Method.invokeNative(Native Method)
08-29 12:21:11.839: E/TiApplication(28397): 	at java.lang.reflect.Method.invoke(Method.java:525)
08-29 12:21:11.839: E/TiApplication(28397): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-29 12:21:11.839: E/TiApplication(28397): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-29 12:21:11.839: E/TiApplication(28397): 	at dalvik.system.NativeStart.main(Native Method)
08-29 12:21:11.839: E/AndroidRuntime(28397): FATAL EXCEPTION: main
08-29 12:21:11.839: E/AndroidRuntime(28397): java.lang.NullPointerException
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.view.ViewConfiguration.get(ViewConfiguration.java:318)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.view.View.<init>(View.java:3264)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.view.View.<init>(View.java:3315)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.widget.TextView.<init>(TextView.java:619)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.widget.TextView.<init>(TextView.java:614)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.widget.TextView.<init>(TextView.java:610)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.modules.titanium.ui.widget.TiUILabel$1.<init>(TiUILabel.java:40)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.modules.titanium.ui.widget.TiUILabel.<init>(TiUILabel.java:39)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.modules.titanium.ui.LabelProxy.createView(LabelProxy.java:55)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:452)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:438)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.map.TiMapInfoWindow.setLeftOrRightPane(TiMapInfoWindow.java:179)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.map.AnnotationProxy.processOptions(AnnotationProxy.java:162)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.map.TiUIMapView.addAnnotation(TiUIMapView.java:268)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.map.TiUIMapView.processPreloadAnnotations(TiUIMapView.java:71)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at ti.map.TiUIMapView.onViewCreated(TiUIMapView.java:87)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at org.appcelerator.titanium.view.TiUIFragment.handleMessage(TiUIFragment.java:58)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.os.Handler.dispatchMessage(Handler.java:95)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.os.Looper.loop(Looper.java:137)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at android.app.ActivityThread.main(ActivityThread.java:5103)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at java.lang.reflect.Method.invokeNative(Native Method)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at java.lang.reflect.Method.invoke(Method.java:525)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-29 12:21:11.839: E/AndroidRuntime(28397): 	at dalvik.system.NativeStart.main(Native Method)
It seems to be related to the annotations on the multiple pins inside the mapView. The mapView code in question is very simple (follows the code of the window that causes this crash): PS: ui. is my global mapping of Ti.UI with predefined UI widgets. map. is the Maps v2 Module (require("ti.map"))
Window = function() {


    var w = ui.window({
        backgroundColor: "#777",
        opacity: 1,
        orientationModes: [Ti.UI.PORTRAIT],
        navBarHidden: true,
        fullscreen: false,
        titleLabel: "Mapa",
        noSets: true
    });


    var m = map.createView({
        maptype: map.NORMAL_TYPE,
        region: {
            latitude: -23.584038,
            longitude: -46.679044,
            latitudeDelta: 0.01,
            longitudeDelta: 0.01
        },
        animate: true,
        userLocation: true,
        height: Ti.UI.FILL,
        width: Ti.UI.FILL,
        top: 46,
        left: 0
    });

    w.add(m);

    Ti.App.addEventListener("missionspop", function() {

        api.missions.near.forEach(function(mi) {
            var pinPay = ui.label({
                text: "R$ " + Number(mi.pay).toFixed(2).replace(".", ","),
                color: "#000",
                height: 40,
                width: 40,
                touchEnabled: false
            });

            var pin = map.createAnnotation({
                pincolor: map.ANNOTATION_AZURE,
                latitude: mi.location[0],
                longitude: mi.location[1],
                title: mi.title,
                subtitle: mi.address,
                leftView: pinPay,
                animate: false,
                mission: mi
            });

            m.addAnnotation(pin);
        });
    });
    
    m.addEventListener("click", function(e) {
        
        if (e.clicksource && e.clicksource != "pin") {
            var missionview = require("mission")(e.annotation.mission);
            missionview.open();
        }
    });


    return w;
}

module.exports = Window;

Comments

  1. Motiur Rahman 2013-09-18

    Hi Ygor Lemos, It seems to me that something wrong in your code, because i have tested this several device it works, you can follow [this link](http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Map) properly. As far as i know you will get help and mind it you must registered API key from Google otherwise it will not works. Thanks
  2. Ygor Lemos 2013-09-26

    I have an app in production running for over 20k users on the App Store. The vast majority has no problems at all with the map. A few users still experience this error. I don't believe it is related to the implementation code at all.
  3. john adamis 2013-10-19

    I managed to reproduce this issue with 2 different devices. This happened in an alloy project if i openeded a new window containing the map then closing this with back button and quickly opening the map window again. This might not always happend the first time but after a couple of tries always occurs. Note that this only occurs in 3.1.2 and above. No crash if running in 3.1.0 or 3.1.1
  4. Mostafizur Rahman 2013-12-15

    We tried to reproduce this issue in-house but were not able to reproduce with the sample test case with Titanium SDK 3.1.3.GA. Please verify with the sample provided and let us know if the issue persists.

    Testing Environment:

    Android SDK: 4.2.2 Titanium SDK: 3.1.3 Titanium CLI Version: 3.1.2 h5. Test Code
       var Map = require('ti.map');
       	var win = Titanium.UI.createWindow();
        
       	var pinView = Titanium.Map.createAnnotation({
       		latitude : -23.584038,
       		longitude : -46.679044,
       		title : "Pin Test",
       		subtitle : 'Pin',
       		pincolor : Titanium.Map.ANNOTATION_RED,
       		animate : true,
       		leftButton : '../images/small.png',
       		myid : 1 // Custom property to uniquely identify this annotation.
       	});
        
       	var mapview = Titanium.Map.createView({
       		mapType : Titanium.Map.STANDARD_TYPE,
       		region: {
                   latitude: -23.584038,
                   longitude: -46.679044,
                   latitudeDelta: 0.01,
                   longitudeDelta: 0.01
               },
       		animate : true,
       		regionFit : true,
       		userLocation : true,
       		annotations : [pinView]
       	});
        
       	win.add(mapview);
       	// Handle click events on any annotations on this map.
       	mapview.addEventListener('click', function(evt) {
        
       		Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid);
        
       	});
        
       	win.open();
       
    tiapp.xml
       ~~~~~~
       <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
                   <!-- Allows the API to download data from Google Map servers -->
                   <uses-permission android:name="android.permission.INTERNET"/>
                   <!-- Allows the API to cache data -->
                   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
                   <!-- Use GPS for device location -->
                   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
                   <!-- Use Wi-Fi or mobile connection for device location -->
                   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
                   <!-- Allows the API to access Google web-based services -->
                   <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
                   <!-- Specify OpenGL ES 2.0 as a requirement -->
                   <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
                   <!-- Replace com.domain.appid with your application ID -->
                   <uses-permission android:name="APPID.permission.MAPS_RECEIVE"/>
                   <permission android:name="APPID.permission.MAPS_RECEIVE"
                       android:protectionLevel="signature"/>
                   <application>
                       <!-- Replace "PASTE YOUR GOOGLE MAPS API KEY HERE" with the Google API key you obtained -->
                       <meta-data android:name="com.google.android.maps.v2.API_KEY"
                           android:value="APIKEY"/>
                   </application>
               </manifest>
           </android>
       
       ~~~~~~
       

    Step to test

    Create a sample Project.

    Paste this code in app.js file.

    Add the ti.map module in tiapp.xml file

    Paste the xml file in tiapp.xml file and update the AppId and API KEY to this.

    Run this code with testing environment.

  5. Ritu Agrawal 2014-01-17

    [~ygbr][~peaceofmind7] There were quite a few issues (crashes and memory leaks) with native Android Maps feature that have been resolved in last few months. We have also fixed a number of maps crashes in 3.2.0 release. We would suggest you to upgrade to the latest SDK and Maps module and let us know if you can reproduce this problem. We would be happy to diagnose this issue with you if you can reproduce it even after the upgrade.

JSON Source