我想創建一個簡單的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/ –