Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2440] Android: Ti.map crashes when adding / selecting annotations

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsMap
Labelsn/a
ReporterRaymond Verbruggen
AssigneeYordan Banev
Created2018-02-08T07:57:25.000+0000
Updated2018-07-25T10:19:46.000+0000

Description

This specific app is used already several years. Now it gives the following error and crashes. Ti SDK 6.3 Ti.map version 4.0.0 and version 3.3.1 (both crash) Android 7.0 Samsung S7 edge SM-G995F http://schemas.android.com/apk/res/android"> [ERROR] : TiApplication: (main) [794,31938] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.model.Marker com.google.android.gms.maps.GoogleMap.addMarker(com.google.android.gms.maps.model.MarkerOptions)' on a null object reference; Titanium 6.3.0,2017/10/31 18:13,undefined [ERROR] : TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.model.Marker com.google.android.gms.maps.GoogleMap.addMarker(com.google.android.gms.maps.model.MarkerOptions)' on a null object reference [ERROR] : TiApplication: at ti.map.TiUIMapView.addAnnotation(TiUIMapView.java:440) [ERROR] : TiApplication: at ti.map.TiUIMapView.addAnnotations(TiUIMapView.java:451) [ERROR] : TiApplication: at ti.map.TiUIMapView.updateAnnotations(TiUIMapView.java:460) [ERROR] : TiApplication: at ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:280) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1096) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:363) [ERROR] : TiApplication: at ti.map.ViewProxy.handleMessage(ViewProxy.java:249) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:154) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:6692) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

Comments

  1. Mostafizur Rahman 2018-02-08

    Hello [~ray@raymondverbruggen.nl],Thanks for sharing with us. Please create a full reproducible test code, test it with latest TI SDK 7.0.1.GA and let us know. Also, provide detail affected environment. Thanks. Thanks.
  2. Raymond Verbruggen 2018-02-08

    Hello! I cannot test with Ti SDK 7, this is an update of an existing app which is in PlayStore. Testing with SDK 7 requires Studio updated to vs 5, which yesterday I had to rollback from because of lots of other problems. I need to update this app only for 2 lines, which cannot take more than 15 minutes. Why do suddenly errors occur? The code (21000 lines in total) was retrieved from SVN from latest version which is in PlayStore. What do you mean with "detail affected document"? Thank you.
  3. Raymond Verbruggen 2018-02-08

    Hello! I cannot test with SDK7 because of the following: [ERROR] : Found incompatible Titanium Modules: [ERROR] : id: com.logicallabs.bluetoothle version: 1.2.9 platform: android min sdk: 6.1.0.GA [ERROR] : id: com.logicallabs.bluetoothle version: 1.2.8 platform: android min sdk: 3.1.0.GA [ERROR] : id: com.logicallabs.bluetoothle version: 1.2.10 platform: android min sdk: 6.1.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 5.3.3 platform: android min sdk: 6.0.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 5.3.1 platform: android min sdk: 6.0.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 5.0.1 platform: android min sdk: 6.0.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 4.15.0 platform: android min sdk: 2.1.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 1.1.2 platform: android min sdk: 2.1.0.GA
  4. Raymond Verbruggen 2018-02-08

    Also I got this message: [WARN] : Building with Android SDK API 26 which hasn't been tested against Titanium SDK 7.0.1 This is not in line with the Titanium Compatibility matrix... So I changed to 25: Update the android:targetSdkVersion in the tiapp.xml or custom AndroidManifest to at least 25: http://ti.appcelerator.org"> [ERROR] : The target SDK API version must be 25 or newer
  5. Hans Knöchel 2018-02-08

    The latest Android one is 4.1.1 (currently in beta, fixing leaks as well), see the [releases](https://github.com/appcelerator-modules/ti.map/releases) for details. You might want to rebuild the version for SDK 6.x, but as SDK 7 resolved all issues regarding google play-services from the past, you may need to re-include the play-services. [~gmathews] where are we with 4.1.1? I think MOD-2378 is the related ticket.
  6. Raymond Verbruggen 2018-02-08

    Found out that it no longer crashes when I do not add annotations. Any idea why? It worked perfectly fine for several years... @Hans Knochel, do you think it has to do with play-services?
  7. Hans Knöchel 2018-02-08

    Yeah, then it's definitely the fix in 4.1.1. I think the issue wasn't there in earlier versions because it was triggered by a PR supporting blob images inside annotation (community one). I can try to rebuild it for you without play-services. *EDIT*: Have fun: https://github.com/hansemannn/ti.map/releases/tag/android-3.3.2
  8. Raymond Verbruggen 2018-02-08

    I tested without images in annotations, so only text but it still crashes. Yes if you can make the Ti.map module so that it works for SDK 6.3.0 that would be superrrrr :) Don't know why but SDK 7 finds incompatible Titanium Modules: [ERROR] : id: com.logicallabs.bluetoothle version: 1.2.9 platform: android min sdk: 6.1.0.GA [ERROR] : id: com.logicallabs.bluetoothle version: 1.2.8 platform: android min sdk: 3.1.0.GA [ERROR] : id: com.logicallabs.bluetoothle version: 1.2.10 platform: android min sdk: 6.1.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 5.3.3 platform: android min sdk: 6.0.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 5.3.1 platform: android min sdk: 6.0.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 5.0.1 platform: android min sdk: 6.0.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 4.15.0 platform: android min sdk: 2.1.0.GA [ERROR] : id: com.mirasense.scanditsdk version: 1.1.2 platform: android min sdk: 2.1.0.GA This is strange isn't it? Nothing is mentioned in the release notes...
  9. Hans Knöchel 2018-02-08

    Titanium SDK 7 added 64-Bit support for Android (better performance, Chrome DevTools debugging, ...), requiring native modules to be recompiled like iOS back in SDK 3.5.0. The modules look like third-party modules (com.mirasense.scanditsdk and com.logicallabs.bluetoothle), so they need to provide new versions. All core-modules (ti.map, ti.facebook, ti.touchid, etc.) have been recompiled before the release already.
  10. Raymond Verbruggen 2018-02-08

    Sorry, version 3.3.2 crashes... [ERROR] : TiApplication: (main) [970,16238] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.model.Marker com.google.android.gms.maps.GoogleMap.addMarker(com.google.android.gms.maps.model.MarkerOptions)' on a null object reference; Titanium 6.3.0,2017/10/31 18:13,undefined [ERROR] : TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.model.Marker com.google.android.gms.maps.GoogleMap.addMarker(com.google.android.gms.maps.model.MarkerOptions)' on a null object reference [ERROR] : TiApplication: at ti.map.TiUIMapView.addAnnotation(TiUIMapView.java:440) [ERROR] : TiApplication: at ti.map.TiUIMapView.addAnnotations(TiUIMapView.java:451) [ERROR] : TiApplication: at ti.map.TiUIMapView.updateAnnotations(TiUIMapView.java:460) [ERROR] : TiApplication: at ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:280) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1096) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:363) [ERROR] : TiApplication: at ti.map.ViewProxy.handleMessage(ViewProxy.java:258) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:168) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5845) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
  11. Hans Knöchel 2018-02-08

    This ticket is missing the test-case, can you attach that? Will move to MOD to validate then.
  12. Raymond Verbruggen 2018-02-08

    All Android modules needed to be updated when SDK6 came along. In the SDK7 release notes there is nothing mentioned about that user modules need to be updated. The SDK6 release notes had that clearly stated http://docs.appcelerator.com/platform/latest/#!/guide/Titanium_SDK_6.0.0_Changes-section-src-48431315_TitaniumSDK6.0.0Changes-RebuildingAndroidModules. For example the Bluetooth module it took almost a year before an updated module came out. Most of the apps I have developed make use of Bluetooth (in combination with custom electronics). So making such breaking changes is very risky... Maybe this is not the correct place to put this but personally I think every developer needs to be able to painless update existing apps. For example the update I am already struggling with the last 2 days is basically a 2-line change, which normally would have taken me 15 minutes to create a new PlayStore update. Developers like me do not have the means for doing big updates. Either in time, money or opportunities. Could you please make an official page in the documentation about how to maintain existing apps? In terms of CLI, SDK, Nodejs, Studio, Atom, VSCODE etc. Maybe there is a need to keep parallel installations or scripts to switch toolchains, node versions or whatever. For example how can I update or rebuild an app that has been released using SDK 5.5 (I have 3 apps which make use of several SDK6 incompatible modules which will never be updated).
  13. Raymond Verbruggen 2018-02-08

    Sorry Hans, but I cannot add the sources of this app. I have a non-dislosure agreement with my customer, and besides that it is a big amount of lines of code... I found this in the log; might be helpful: [INFO] : Google Play services is installed. [ERROR] : MapViewProxy: (KrollRuntimeThread) [36,15268] Unsupported argument type for removeAnnotation [WARN] : System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000003/n/armeabi [INFO] : System: exec(/system/bin/getprop debug.mapview.logs @ com.google.maps.api.android.lib6.common.o.a:33) [INFO] : I/Google Maps Android API: Google Play services client version: 10298000 [INFO] : I/Google Maps Android API: Google Play services package version: 11975438 This is the part of the source code that makes the difference between crashing and not crashing: Would that be enough? The line with "mapview.annotations = annotations;" makes the diff. When I comment that line the app does not crash. var MapModule = require('ti.map'); var locationPermission = "android.permission.ACCESS_FINE_LOCATION"; var hasLocationPermission = Ti.Android.hasPermission(locationPermission); var permissionsToRequest = []; if (!hasLocationPermission) { permissionsToRequest.push(locationPermission); } if (permissionsToRequest.length > 0) { Ti.Android.requestPermissions(permissionsToRequest, function(e) { if (e.success) { Ti.API.info("SUCCESS"); win.open(); } else { Ti.API.info("ERROR: " + e.error); } }); } // -------------------------------------------------------------------- // check if google play services are installed // -------------------------------------------------------------------- if (OS_ANDROID) { var rc = MapModule.isGooglePlayServicesAvailable(); switch (rc) { case MapModule.SUCCESS: Ti.API.info('Google Play services is installed.'); break; case MapModule.SERVICE_MISSING: alert('Google Play services is missing. Please install Google Play services from the Google Play store.'); break; case MapModule.SERVICE_VERSION_UPDATE_REQUIRED: alert('Google Play services is out of date. Please update Google Play services.'); break; case MapModule.SERVICE_DISABLED: alert('Google Play services is disabled. Please enable Google Play services.'); break; case MapModule.SERVICE_INVALID: alert('Google Play services cannot be authenticated. Reinstall Google Play services.'); break; default: alert('Unknown error.'); break; } } var mapview = MapModule.createView({ mapType : MapModule.NORMAL_TYPE, userLocation : false, animate : true, enableZoomControls : false }); $.mapContainer.add(mapview); mapview.region = { latitude : '51.94067', longitude : '6.48117', latitudeDelta : 4, longitudeDelta : 4 }; // all annotations are kept in a database Alloy.Collections.partners = Alloy.createCollection('partners'); var partners = Alloy.Collections.partners; var count = 1; var annotations = []; partners.fetch({ success : function() { _.each(partners.models, function(e) { var m = e.toJSON(); if ((m.latitude != null) && (m.longitude != null) && (m.latitude != '') && (m.longitude != '')) { var ann = MapModule.createAnnotation({ latitude : m.latitude, longitude : m.longitude, title : m.companyname, subtitle : m.postalcode + ' ' + m.town, rightButton : '/images/info.png', id : m // custom property to uniquely identify this annotation }); if (m.mapicon == 1) ann.image = 'images/vb.png'; else if (m.mapicon == 2) ann.pincolor = MapModule.ANNOTATION_PURPLE; else if (m.mapicon == 3) ann.pincolor = MapModule.ANNOTATION_RED; annotations.push(ann); } }); mapview.annotations = annotations; }, error : function() { Ti.API.error("hmm - this is not good!"); } });
  14. Raymond Verbruggen 2018-02-08

    Found this, maybe useful? https://stackoverflow.com/questions/40770073/appcelerator-android-crashes-with-ti-map-module-on-some-devices
  15. Raymond Verbruggen 2018-02-09

    Good morning Hans, my customer agreed to let me split the 'big' app into a one page app with only the mapview. Would that help you? Then I would like to send that project to you via email or so. Please let me know. Best regards, Raymond
  16. Raymond Verbruggen 2018-02-09

    Continued testing; it is solved if I do not make an array of annotations first and then add this array to the mapview, but add every annotation to the mapview itself. Both with Ti.map module version 3.3.1 and 3.3.2. No idea why, maybe this helps?
  17. Sharif AbuDarda 2018-02-09

    Hello, Please peovide a full reproducible code that regenrates the issue. Thanks.
  18. Mostafizur Rahman 2018-02-19

    Hello [~ray@raymondverbruggen.nl], Just passing a followup here.Are you able to get that sorted out? If not please provide a full reproducible code that regenerates the issue. Please let us know if you need more help with this issue. Regards
 Axway Appcelerator Support
  19. Raymond Verbruggen 2018-02-21

    Hello, good morning! In one of my earlier comments I asked this: _Good morning Hans, my customer agreed to let me split the 'big' app into a one page app with only the mapview. Would that help you? Then I would like to send that project to you via email or so._ Please let me know if this is possible. I cannot post all files here (especially the database with annotations) because that contains customer sensitive info :) Best regards, Raymond
  20. Michael Gangolf 2018-07-10

    I have this error too in a project:
        [WARN]  W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.model.Marker.remove()' on a null object reference
        [WARN]  W/System.err: 	at ti.map.TiUIMapView.addAnnotation(TiUIMapView.java:474)
        [WARN]  W/System.err: 	at ti.map.TiUIMapView.addAnnotations(TiUIMapView.java:489)
        [WARN]  W/System.err: 	at ti.map.TiUIMapView.updateAnnotations(TiUIMapView.java:498)
        [WARN]  W/System.err: 	at ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:288)
        [WARN]  W/System.err: 	at org.appcelerator.kroll.KrollProxy.firePropertyChanged(KrollProxy.java:969)
        [WARN]  W/System.err: 	at org.appcelerator.kroll.KrollProxy.onPropertyChanged(KrollProxy.java:1058)
        [WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
        [WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:55)
        [WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:41)
        [WARN]  W/System.err: 	at ti.modules.titanium.TitaniumModule$Timer.run(TitaniumModule.java:166)
        [WARN]  W/System.err: 	at android.os.Handler.handleCallback(Handler.java:751)
        [WARN]  W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:95)
        [WARN]  W/System.err: 	at android.os.Looper.loop(Looper.java:173)
        [WARN]  W/System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6459)
        [WARN]  W/System.err: 	at java.lang.reflect.Method.invoke(Native Method)
        [WARN]  W/System.err: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938)
        [WARN]  W/System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)
        
    Tried ti.map version 4.2.0+ It looks like at https://github.com/appcelerator-modules/ti.map/blob/master/android/src/ti/map/TiUIMapView.java#L498 tiMarker.getMarker() is null but tiMarker isn't. Guarding this will remove this error but I can't show/hide markers anymore. I have an array of annotations which I filter and use setAnnotations to set them. I'll try to make a test app to reproduce the error and try to find a solution :)
  21. Michael Gangolf 2018-07-10

    Example:
        var Map = require('ti.map');
        var win = Titanium.UI.createWindow();
        var mapview = Map.createView({
        	bottom: 0,
        	right: 0,
        	width: Ti.UI.FILL,
        	height: Ti.UI.FILL,
        	rotateEnabled: true,
        	mapType: Map.MUTED_STANDARD_TYPE,
        	showsPointsOfInterest: false,
        	userLocation: true,
        });
        var ann = [];	// store annotations
        
        function setData() {
        	for (var i = 0; i < 10; i++) {
        		ann.push(Map.createAnnotation({
        			title: 'Title',
        			subtitle: 'subtitle',
        			latitude: Math.random() * 10 + 40,
        			longitude: Math.random() * 10,
        		}));
        	}
        	mapview.setAnnotations(ann);
        }
        setData();
        
        
        var btn = Ti.UI.createButton({
        	title: "add again",
        	bottom: 40
        });
        var btn2 = Ti.UI.createButton({
        	title: "add new",
        	bottom: 0
        });
        var btn3 = Ti.UI.createButton({
        	title: "set",
        	bottom: 80
        });
        btn.addEventListener("click", function() {
        	// remove and add existing annotation
        	mapview.removeAllAnnotations();
        	mapview.addAnnotation(ann[0]);
        })
        
        btn2.addEventListener("click", function() {
        	// create new annotation and set it
        	var anno = Map.createAnnotation({
        		title: 'Title',
        		subtitle: 'subtitle',
        		latitude: Math.random() * 10 + 40,
        		longitude: Math.random() * 10,
        	})
        	mapview.setAnnotations([anno]);
        })
        
        btn3.addEventListener("click", function() {
        	// reset existing annotation
        	mapview.setAnnotations([ann[0]]);
        })
        win.add(btn);
        win.add(btn2);
        win.add(btn3);
        win.add(mapview);
        win.open();
        
        
    Only the button "Add new" works. If I add or set an existing icon it will crash. Android 7 (HTC A9) Ti SDK 7.2.0.GA Ti.Map 4.3.0
  22. Yordan Banev 2018-07-17

  23. Michael Gangolf 2018-07-17

    Thanks [~ybanev]! I wasn't sure if they are related that's why I posted the info here, too and later created an own ticket! I'll keep an eye on both tickets of course.

JSON Source