Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Black screen, not show the map #2802

Closed
lmbotero opened this issue Oct 26, 2015 · 30 comments
Closed

Black screen, not show the map #2802

lmbotero opened this issue Oct 26, 2015 · 30 comments
Labels
Android Mapbox Maps SDK for Android bug

Comments

@lmbotero
Copy link

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

@tobrun tobrun added Android Mapbox Maps SDK for Android bug labels Oct 26, 2015
@tobrun
Copy link
Member

tobrun commented Oct 26, 2015

@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

@lmbotero
Copy link
Author

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

@tobrun
Copy link
Member

tobrun commented Oct 26, 2015

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

@tobrun tobrun mentioned this issue Oct 26, 2015
@ljbade
Copy link
Contributor

ljbade commented Oct 27, 2015

@LuisBotero Can you try #2810 to see if it fixes this issue?

@lmbotero
Copy link
Author

@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?

@tobrun
Copy link
Member

tobrun commented Oct 27, 2015

@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.

@bleege
Copy link
Contributor

bleege commented Oct 27, 2015

@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 bleege added this to the android-v2.2.0 milestone Oct 27, 2015
@lmbotero
Copy link
Author

@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!!

@tobrun
Copy link
Member

tobrun commented Oct 27, 2015

@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?

@ljbade
Copy link
Contributor

ljbade commented Oct 27, 2015

@LuisBotero I created an issue for the layout editor bug in #2830

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

@bleege
Copy link
Contributor

bleege commented Oct 27, 2015

@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

@e-mk
Copy link

e-mk commented Oct 28, 2015

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

@bleege
Copy link
Contributor

bleege commented Oct 28, 2015

@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

@e-mk
Copy link

e-mk commented Oct 29, 2015

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

@lmbotero
Copy link
Author

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

@bleege
Copy link
Contributor

bleege commented Oct 29, 2015

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

@bleege bleege closed this as completed Oct 29, 2015
@pkostohrys
Copy link

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

@BrunoDrean
Copy link

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);
    }

@pkostohrys
Copy link

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

@pkostohrys
Copy link

mapView.moveCamera

@BrunoDrean
Copy link

I changed this : mapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, null);

by this :

mapView.setLatLng(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()));

the black screen remains for 1 to 2 seconds, then the map is comeback

@KaiWangCanada
Copy link

This happens to me when you try to move the camera before the mapview is fully loaded.
I'm using 3.2.0

@tobrun
Copy link
Member

tobrun commented Mar 21, 2016

This should not occur with 4.0.0 anymore. a workaround for 3.2.0 is to use the OnMapChangeListener and wait for the DID_FINISH_LOADING_MAP callback

@leocarona
Copy link

I started having issue with seen black screen instead of the tiles. It turned out that the app was reinstalled on my phone, so it lost the tiles that were previously loaded, and since my phone wasn't connected to any internet, the tiles were not been downloaded. A bit stupid, but I wanted to comment this here in case someone else gets to this page because they might be doing the same =)

@Insane-neal
Copy link

In China, VPN is required to visit mapbox server. Otherwise the screen is black. Do you have a local server?

@tobrun
Copy link
Member

tobrun commented Apr 10, 2018

@Insane-neal, yes we do, see https://www.mapbox.cn/, reach out to support for more details

@zugaldia
Copy link
Member

cc: @chriswu42

@chriswu42
Copy link

In China, VPN is required to visit mapbox server. Otherwise the screen is black. Do you have a local server?

@Insane-neal we cannot guarantee complete stability hitting our api.mapbox.com endpoint from inside China due to implications with the Great Firewall. For faster and more stable services we recommend reaching out to us for using api.mapbox.cn endpoint hosted via servers based in China.

@Insane-neal
Copy link

@chriswu42 Thanks for the reply. I dont know how it works. So I have submitted a request, should someone contact me? It's been a day and nothing happens till now.
Since it is required to use an access token, which seems need a connection to cross the GFW, is this process stable?

@chriswu42
Copy link

@Insane-neal we currently don't provide free API access to our api.mapbox.cn endpoint since servers in China are very expensive to run, please reach out to our sales team if you decide to move forward here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug
Projects
None yet
Development

No branches or pull requests