Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when Google Map is added #50

Closed
shufaz opened this issue Jan 30, 2014 · 11 comments
Closed

Crash when Google Map is added #50

shufaz opened this issue Jan 30, 2014 · 11 comments

Comments

@shufaz
Copy link

shufaz commented Jan 30, 2014

App always crashes when I added map to the centerView. There was no problem with the map itself since I've tested it without NappDrawer. Anyone had this figured out - or NappDrawer doesn't support map?

Building with Titanium SDK 3.2, on android, with Google Maps v2 (2.1.3 version module)

Thanks in advance for any help.

@bitfabrikken
Copy link
Contributor

I too have the crashing problem.

I'm just not sure if it's only with NappDrawer it happens, but it does happen.
Apparantly according to the following it has to do with the Holo theme.

A Q&A here discusses it in more detail: http://developer.appcelerator.com/question/151567/google-maps-v2-module-crashes-when-view-placed-in-tab-group

And a bugticket on JIRA here: https://jira.appcelerator.org/browse/TIMODOPEN-230

Another JIRA: https://jira.appcelerator.org/browse/TIMOB-13864

The tickets appear to be largely ignored by Appcelerator though, so it would be nice if we could find a solution for this!

My temporary workaround has been to create a new view and add the map to that. Then I replace the existing centerView with this new one. This seems the prevent the crash.

@shufaz
Copy link
Author

shufaz commented Jan 30, 2014

Here's my simple code:

var NappDrawerModule = require('dk.napp.drawer');
var MapModule = require('ti.map');

var leftMenuView = Ti.UI.createView({
backgroundColor:'red',
});

var centerView = Ti.UI.createView({
backgroundColor:'blue',
});

var mapView = MapModule.createView({
userLocation: true,
mapType: MapModule.NORMAL_TYPE,
animate: true,
region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 },
height:'100%',
width:'100%',
});
centerView.add(mapView);

var mainWindow = NappDrawerModule.createDrawer({
leftWindow:leftMenuView,
centerWindow:centerView,
leftDrawerWidth: "260dp",
navBarHidden:true,
});
mainWindow.open();

bitfabrikken, is your workaround something like this? It's still crashing... all the time. I have no problem with the map alone...

@bitfabrikken
Copy link
Contributor

Added a bit to your example code, which makes it work.. But it's weird.

var NappDrawerModule = require('dk.napp.drawer');
var MapModule = require('ti.map');

var leftMenuView = Ti.UI.createView({
    backgroundColor:'red',
});

var centerView = Ti.UI.createView({
    backgroundColor:'blue',
});

var mapView = MapModule.createView({
    userLocation: true,
    mapType: MapModule.NORMAL_TYPE,
    animate: true,
    region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 }, 
    height:'100%',
    width:'100%',
});
//centerView.add(mapView); //don't add mapView yet!

var mainWindow = NappDrawerModule.createDrawer({
    leftWindow:leftMenuView,
    centerWindow:centerView,
    leftDrawerWidth: "260dp",
    navBarHidden:true,
});
mainWindow.open();

//for some reason, this works..
mainWindow.addEventListener('open',function(){
    var new_view = Ti.UI.createView({
        backgroundColor:'purple',
    });
    mainWindow.setCenterWindow(new_view);   
    setTimeout(function(){
        new_view.add(mapView);
    },1000);    
});

@shufaz
Copy link
Author

shufaz commented Feb 1, 2014

Hey it works!! Thanks a lot for the workaround, bitfabrikken! Yes it is a bit weird, but it'll do for now until a better solution comes out. Thanks again.

@shufaz
Copy link
Author

shufaz commented Feb 3, 2014

Update: Unfortunately, this doesn't work on newer android devices. I tried on Samsung Galaxy W, Android 2.3... it works just fine, but when tried on S3 and Note 3, it crashes everytime...

@bitfabrikken
Copy link
Contributor

The fix works for me on Nexus 4, Nexus 5 and Nexus 7 (the first model).

@bitfabrikken
Copy link
Contributor

@viezel - do you have any ideas on this issue? Maybe it's not your module, but the module it's built on? Or maybe a general Titanium thing?

@viezel
Copy link
Owner

viezel commented Feb 5, 2014

im almost sure it has nothing to do with my module. I know their are certain bugs in jira regarding the new map module.
If you look at the source code for NappDrawer you will find that I open 3 views and do some custom animations to make them slide in and out. Thats about it. nothing super fancy, that should break google maps.

@viezel viezel closed this as completed Apr 16, 2014
@Brian-McBride
Copy link

Viezel,

I know you closed this issue, but regardless of what solution I use posted, I cannot get a map drawn in the centerView without crashing the app. I can put it on a setInterval delay of 5000ms and still, once the add method is called - crash.

This is a bit of the XML I used in the alloy to set the main view area:

















@albert0m
Copy link

this is still happening, did anyone find a workaround?

@Max87ZA
Copy link

Max87ZA commented Feb 12, 2018

I have this problem for a long time and finally @bitfabrikken solution works for me. Important thing is, that you have to add mapView after drawer opens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants