Search code examples
androidopengl-esmapboxgenymotion

Mapbox example map not working with Android Studio/Genymotion


So I have been working with Android Studio and Mapbox for roughly 3 months and last week i decided to do a clean format of my PC. I reinstalled my drivers, updated AS and reinstalled Genymotion (I use it to emulate). But now I am getting an error every time I attempt to compile and run the Simple Mapbox Example.

It says I need to assign an API key to MapView but I already did with the MapBoxAccountManager. When I do however assign the API key to MapView in the .xml i get the error below.

The thing is that I have used the same API key before and never had this issue, if i compile the hello world project it works perfectly.

Here is the logcat:

07-06 09:28:21.797 4780-4780/com.example.brian.mapboxdemo W/art: Failed to find OatDexFile for DexFile /data/data/com.example.brian.mapboxdemo/files/instant-run/dex/slice-slice_9-classes.dex ( canonical path /data/data/com.example.brian.mapboxdemo/files/instant-run/dex/slice-slice_9-classes.dex) with checksum 0x69babcd9 in OatFile /data/data/com.example.brian.mapboxdemo/cache/slice-slice_9-classes.dex
07-06 09:28:22.170 4780-4780/com.example.brian.mapboxdemo I/art: Thread[1,tid=4780,WaitingForJniOnLoad,Thread*=0xf4406800,peer=0x742ef970,"main"] recursive attempt to load library "/data/app/com.example.brian.mapboxdemo-1/lib/x86/libmapbox-gl.so"
07-06 09:28:22.170 4780-4780/com.example.brian.mapboxdemo I/art: Thread[1,tid=4780,WaitingForJniOnLoad,Thread*=0xf4406800,peer=0x742ef970,"main"] recursive attempt to load library "/data/app/com.example.brian.mapboxdemo-1/lib/x86/libmapbox-gl.so"
07-06 09:28:22.210 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Telemetry initialize() called...
07-06 09:28:22.214 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Right before Telemetry set enabled in initialized()
07-06 09:28:22.216 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: setTelemetryEnabled(); this.telemetryEnabled = false; telemetryEnabled = true
07-06 09:28:22.216 4780-4780/com.example.brian.mapboxdemo D/MapboxEventManager: Starting Telemetry Up!
07-06 09:28:22.218 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Permissions are good, see if GPS is enabled and if not then setup Ambient.
07-06 09:28:22.221 4780-4780/com.example.brian.mapboxdemo E/MapboxEventManager: Error Trying to load Staging Credentials: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
07-06 09:28:22.222 4780-4780/com.example.brian.mapboxdemo I/com.mapbox.mapboxsdk.maps.MapView: MapView start Telemetry...
07-06 09:28:22.222 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Telemetry initialize() called...
07-06 09:28:22.222 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Mapbox Telemetry has already been initialized.
07-06 09:28:22.224 4780-4780/com.example.brian.mapboxdemo D/libEGL: loaded /system/lib/egl/libEGL_emulation.so
07-06 09:28:22.224 4780-4780/com.example.brian.mapboxdemo D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
07-06 09:28:22.228 4780-4780/com.example.brian.mapboxdemo D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so

                                                                [ 07-06 09:28:22.233  4780: 4780 D/         ]
                                                                HostConnection::get() New Host Connection established 0xeb7259b0, tid 4780
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Vendor: Android
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Version: 1.4 Android META-EGL
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Client APIs: OpenGL_ES
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Client Extensions: EGL_KHR_get_all_proc_addresses EGL_ANDROID_presentation_time EGL_KHR_image_base EGL_KHR_fence_sync EGL_ANDROID_image_native_buffer 
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo W/mbgl: [Android]: In emulator! Enabling hacks :-(
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Found 8 configs
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 0:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 1:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 2:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 3:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 4:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 5:
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 6:
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 7:
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Chosen config is 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Chosen window format is 1
07-06 09:28:22.310 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: flushEventsQueueImmediately() called...
07-06 09:28:22.312 4780-4780/com.example.brian.mapboxdemo D/MapboxEventManager: turnstile event pushed.
07-06 09:28:22.318 4780-4836/com.example.brian.mapboxdemo D/OpenGLRenderer: Render dirty regions requested: true
07-06 09:28:22.323 4780-4780/com.example.brian.mapboxdemo D/Atlas: Validating map...
07-06 09:28:22.330 4780-4780/com.example.brian.mapboxdemo I/TelemetryService: onCreate() called
07-06 09:28:22.331 4780-4780/com.example.brian.mapboxdemo I/TelemetryService: onStartCommand() called
07-06 09:28:22.351 4780-4836/com.example.brian.mapboxdemo I/OpenGLRenderer: Initialized EGL, version 1.4

                                                                        [             07-06 09:28:22.351  4780: 4836 D/         ]
                                                                        HostConnection::get() New Host Connection established 0xe3d0b710, tid 4836
07-06 09:28:22.398 4780-4836/com.example.brian.mapboxdemo D/OpenGLRenderer: Enabling debug mode 0
07-06 09:28:22.446 4780-4836/com.example.brian.mapboxdemo W/EGL_emulation: eglSurfaceAttrib not implemented
07-06 09:28:22.446 4780-4836/com.example.brian.mapboxdemo W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe3d07ea0, error=EGL_SUCCESS
07-06 09:28:22.535 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Vendor: Google (ATI Technologies Inc.)
07-06 09:28:22.546 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Renderer: Android Emulator OpenGL ES Translator (AMD Radeon R9 200 Series)
07-06 09:28:22.548 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Version: OpenGL ES 2.0 (4.5.13440 Compatibility Profile Context 16.200.1013.0)
07-06 09:28:22.548 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Extensions: GL_EXT_debug_marker GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float GL_OES_texture_npot GL_OES_rgb8_rgba8
07-06 09:28:22.919 4780-4780/com.example.brian.mapboxdemo E/mbgl: [Shader]: Shader failed to compile: Vertex shader failed to compile with the following errors:
                                                              ERROR: 0:6: error(#101) Macro redefined: lowp
                                                              ERROR: 0:7: error(#101) Macro redefined: mediump
                                                              ERROR: 0:8: error(#101) Macro redefined: highp
                                                              ERROR: error(#273) 3 compilation errors.  No code generated
07-06 09:28:22.919 4780-4780/com.example.brian.mapboxdemo E/mbgl: [Shader]: Vertex shader fill failed to compile: precision highp float;
                                                              #ifdef GL_ES
                                                              precision highp float;
                                                              #else
                                                              #define lowp
                                                              #define mediump
                                                              #define highp
                                                              #endif

                                                              attribute vec2 a_pos;

                                                              uniform mat4 u_matrix;

                                                              void main() {
                                                                  gl_Position = u_matrix * vec4(a_pos, 0, 1);
                                                              }


                                                              --------- beginning of crash
07-06 09:28:22.920 4780-4780/com.example.brian.mapboxdemo A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdeadcab1 in tid 4780   (rian.mapboxdemo)`

Solution

  • The MapboxAccountManager currently has a bug that will cause the issue you are describing, more info can be found on Github. To get around this for now you can either create an Application java class (example of this can be found in the testapp or you can use the old way (now deprecated) of setting your access token through XML. You can do this by adding this line in your mapview xml layout: mapbox:access_token="<your access token here>".

    I'd also like to note that, although Mapbox should work using an emulator, for the best experience, using a physical device is recommended.