我想创建一个简单的mapbox应用程序,它显示一个mapview。调试时没有显示特定错误,但应用程序在启动时崩溃。这里是我创建的.java文件。Mapbox应用程序崩溃时启动
public class MainActivity extends AppCompatActivity {
private MapView mapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Mapbox.getInstance(this,String.valueOf(R.string.access_token));
setContentView(R.layout.activity_main);
mapView=(MapView)findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
}
});
}
@Override
protected void onStart() {
super.onStart();
mapView.onStart();
}
@Override
protected void onResume() {
super.onResume();
mapView.onResume();
}
@Override
protected void onPause() {
super.onPause();
mapView.onPause();
}
}
这里是我的.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
tools:context="com.example.logusubramaniyan.choropleth1.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTilt="20"
mapbox:mapbox_cameraZoom="12"/>
</LinearLayout>
我不明白为什么活动失败当对模拟器或任何device.Any想法运行启动?
这是我的StackTrace结果。
致命异常:主 工艺:com.example.logusubramaniyan.choropleth1,PID:17191 了java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.logusubramaniyan.choropleth1/com.example.logusubramaniyan.choropleth1 .MainActivity}:android.view.InflateException:二进制XML文件行#16:二进制XML文件行#16:错误在android.app.ActivityThread.performLaunchActivity
向我们展示您的堆栈跟踪崩溃。 – SripadRaj
后logcat请。 –
阅读https://www.mapbox.com/help/first-steps-android-sdk/ –