mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Black screen, not show the map

Open lmbotero opened this issue 11 years ago • 30 comments

When I try to open the map, the screen goes black, and never the map is displayed. I tried doing a new application in Android Studio and I downloaded the demo of the Play Store, I have the same problem in both applications. I'm working on Android version 4.2.2.

screenshot_2015-10-26-11-56-06

lmbotero avatar Oct 26 '15 17:10 lmbotero

@LuisBotero: Could you add the code where you are initializing the map? Can you verify that you are calling the different lifecycle methods?

Linking issue (#2513) with same problem. @bleege @ljbade @zugaldia

tobrun avatar Oct 26 '15 18:10 tobrun

The code are calling the different lifecycle methods correctly, onCreate, onStart, onResume, etc There are some screenshots of my code, the activity_main and MainActivity classes, and also attached some results in the Logcat console when I open my application. The code used is like the example of the documentacion in the website of MapBox Android API.

mainactivity activity_main logcat

lmbotero avatar Oct 26 '15 19:10 lmbotero

@LuisBotero this is great info to have, thank you for that!

tobrun avatar Oct 26 '15 19:10 tobrun

@LuisBotero Can you try https://github.com/mapbox/mapbox-gl-native/pull/2810 to see if it fixes this issue?

ljbade avatar Oct 27 '15 01:10 ljbade

@ljbade I'm still having the same problem, the map is not displayed, I tried with versions 2.1.0 and 2.2.0 of MapBox and none have worked for me. I need to do something extra in my code?

lmbotero avatar Oct 27 '15 13:10 lmbotero

@LuisBotero: @ljbade indicated building from source. A new SNAPSHOT, that you can use as a gradle dependency, will be released later today. Would be awesome if you could test again with that. Will ping you if that SNAPSHOT lands.

tobrun avatar Oct 27 '15 14:10 tobrun

@LuisBotero We just released a new SNAPSHOT from our testing in #2817. Please feel free to give it a shot to make sure we were able to solve the problem. Instructions on how to install it are available at https://www.mapbox.com/android-sdk/#gradle.

Thanks again for reporting this issue and for using the SDK!

bleege avatar Oct 27 '15 16:10 bleege

@bleege I'm still having trouble running my code. The map still shows black screen on my phone and the AVD stops working when I run my application with the map.

This is my build.gradle buildg

This is what I get in my xml xml

And this is my class. class

Am i doing something wrong?. Why my map does not work? I'm working with Android 4.2.2 in the AVD and on my phone. Thank you for your help!!

lmbotero avatar Oct 27 '15 21:10 lmbotero

@LuisBotero

Thank you for sharing your code, I have created a separate project to test this in, I copied your code and loaded it up on a nexus 5 emulator running 4.2.2:

screen shot 2015-10-27 at 23 44 59

It seems that your Gradle is not using the newer version of the SNAPSHOT but rather a cached one. The results you are describing are the same as before the fix of @ljbade for 4.x devices .

Could you try doing a sync gradle with project files? Do you see anything in the logging while running?

tobrun avatar Oct 27 '15 23:10 tobrun

@LuisBotero I created an issue for the layout editor bug in https://github.com/mapbox/mapbox-gl-native/issues/2830

~~What happens if you move mapView.onCreate() above the mapView.set... lines?~~ @tobrun beat me to it, looks like it should work.

ljbade avatar Oct 27 '15 23:10 ljbade

@LuisBotero Thanks for testing it out. A couple of things to try:

  1. Swap the line order of mavenCentral() and maven { url: ""}
  2. Try is to do a force update of the Gradle dependency in the command line while Android Studio is closed and then reopen it so that Android Studio picks up all the changes. I know that's kinda lame, but I've noticed this before.

To force dependency updates:

cd mapbox-gl-native/android/
./gradlew clean --refresh-dependencies

bleege avatar Oct 27 '15 23:10 bleege

I have the same issue. Bleege, tried your instructions but no luck.

e-mk avatar Oct 28 '15 11:10 e-mk

@LuisBotero @ernest95 Thanks for trying to test the SNAPSHOT. I created a simple app (see link below) that shows how to add the SNAPSHOT to an app. Hopefully this helps!

https://github.com/bleege/MapboxSnapshot

bleege avatar Oct 28 '15 15:10 bleege

I'm still having these issue. It works on genymotion virtual devices but shows black screen on all android devices.

e-mk avatar Oct 29 '15 16:10 e-mk

@tobrun @ljbade @bleege Thank you very much for your help. The code is working for me and running fine. device-2015-10-29-110708

lmbotero avatar Oct 29 '15 16:10 lmbotero

Awesome @LuisBotero! Thanks again for bringing this to our attention so that we could fix it. We really appreciate it! :rocket: :rocket:

bleege avatar Oct 29 '15 16:10 bleege

Hi have a black screen after execute

CameraPosition.Builder cameraPosition = new CameraPosition.Builder() .target(position.toBoxLatLng()) .bearing(bearing).tilt(90); if(!isZoomed){ cameraPosition.zoom(16); } isZoomed = true; map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition.build()), 25000, null);

Using com.mapbox.mapboxsdk:mapbox-android-sdk:3.2.0@aar

pkostohrys avatar Feb 28 '16 20:02 pkostohrys

Hello,

I had the same problem, I saw the comment of Pasha0093

I noticed that I was using a "animateCamera" in my onCreate() :

using : com.mapbox.mapboxsdk:mapbox-android-sdk:3.2.0@aar

    cameraPosition = new CameraPosition.Builder()
                .target(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()))
                .zoom(currentZoom)
                .tilt(70)
                .bearing(0)
                .build();

mapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, null);

I deleted this animateCamera in my onCreate() and after that I did not have black screen

But also I use animateCamera for each new location of user (I've not delete it)

@Override
public void onResume() {
     IntentFilter filterIntent = new IntentFilter(Constantes.BROADCAST_LOCATION_FILTER);
            bcReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {              
                    Bundle extras = intent.getExtras(); // on recup. le bundle
                    Location temp = (Location) extras.get("NEW_LOCATION");                  
                    [..]
                    updateMap(userPos.getLatitude(),userPos.getLongitude(),orientationCamera);
                }
            };
}   



private void updateMap(double latitude, double longitude, float orientCam) {

        currentZoom = calculZoom();
        markerUser.position(new LatLng(latitude, longitude));

        cameraPosition = new CameraPosition.Builder()
                .target(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()))
                .zoom(currentZoom)// currentZoom
                .tilt(70)
                .bearing(orientCam)
                .build();

        mapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, null);
    }

BrunoDrean avatar Mar 04 '16 15:03 BrunoDrean

try move camera but it is without animation , about snapshot i cant integrate it in my project

pkostohrys avatar Mar 04 '16 15:03 pkostohrys

mapView.moveCamera

pkostohrys avatar Mar 04 '16 15:03 pkostohrys