尝试在我的应用中加载MapBox视图时出现此错误。我在代码中出错了吗?
测试信息:
Nexus 5X(API 23)Android 6.0 x86_64模拟器,Android Studio 2.2预览版7(Mac)
摇篮:
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.1@aar') {
transitive = true
}
MapActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
MapboxAccountManager.start(this, getString(R.string.accessToken));
// Create a mapView
mapView = (MapView) findViewById(R.id.mapview);
// Doesn't work without using deprecated setAccessToken... bug??
mapView.setAccessToken(getString(R.string.accessToken));
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
}
});
mapView.onCreate(savedInstanceState);
}
XML:
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:style_url="@string/style_mapbox_streets"
mapbox:center_latitude="41.885"
mapbox:center_longitude="-87.679"
mapbox:zoom="12"
mapbox:tilt="20" />
日志:
E/mbgl: [Shader]: Shader failed to compile: ERROR: Valid GLSL but not GLSL ES
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);
}
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdeadcab1 in tid 22621
答案 0 :(得分:1)
您使用的是什么版本的Android工作室,是否在模拟器或物理设备上运行应用程序?经过测试,能够使用测试版的工作室而不是稳定版。
旁注:
MapboxAccountManager.start(this, getString(R.string.accessToken));
如果你在XML中有mapview,那么需要在setContentView()
之前。