[AC-2217] Android: Random Crashes on Google Maps v2 API
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2014-01-17T07:24:49.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android, map, mapview |
Reporter | Ygor Lemos |
Assignee | Ritu Agrawal |
Created | 2013-08-29T15:30:06.000+0000 |
Updated | 2016-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;
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
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.
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
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 Codetiapp.xml
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.
[~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.