Mapbox有许多错误



我尝试将我的应用程序与Mapbox连接。我认为我做的每件事都是正确的,但有一个问题,我不知道我应该怎么做

E/AndroidRuntime:致命异常:main流程:com.softwareengineics.driver,PID:9114java.lang.RuntimeException:无法启动活动ComponentInfo{com.softwarelisting.driver/com.softwarelistes.driver.MainActivity}:android.view.InflateException:com.softwarelistics中的二进制XML文件行#17。driver:layout/activity_main:com.softwarelistics.driver:layout/activity-main:膨胀类com.mapbox.mapboxsdk.mas.MapView时出错在android.app.ActivityThread.performLaunchActivity(ActivityThreads.java:3356)在android.app.ActivityThread.handleLaunchActivity(ActivityThreads.java:3500)在android.app.servertransaction.LaunchActivityItem.exexecute(LaunchActivityItem.java:83)在android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)在android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)在android.app.ActivityThread$H.handleMessage(ActivityThreads.java:2049)在android.os.Handler.dispatchMessage(Handler.java:106)在android.os.Looper.loop(Looper.java:223)在android.app.ActivityThread.main(ActivityThreads.java:7523)位于java.lang.reflect.Method.ioke(本机方法)网址:com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)网址:com.android.internal.os.ZygoteInit.main(ZygoteNit.java:941)由以下原因引起:android.view.InflateException:二进制XML文件行#17(在com.softwareviewics中)。driver:layout/activity_main:二进制XML文件列#17由以下原因引起:android.view.InflateException:com.softwareengineics.driver:layout/activity_main:膨胀类com.mapbox.mapboxsdk.maps.MapView时出错引起原因:java.lang.reflect.InvocationTargetException位于java.lang.reflect.Constructure.newInstance0(本机方法)位于java.lang.reflect.Constructure.newInstance(Constructor.java:343)在android.view.LayoutInflater.createView(LayoutInflater.java:852)在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)在android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)在android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)在android.view.LayoutInflater.inflature(LayoutInflater.java:680)在android.view.LayoutInflater.inflature(LayoutInflater.java:532)在android.view.LayoutInflater.inflature(LayoutInflater.java:479)位于androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDeleateImpl.java:696)位于androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)网址:com.softwareactives.driver.MainActivity.onCreate(MainActivity.kt:19)在android.app.Activity.performCreate(Activity.java:77984)在android.app.Activity.performCreate(Activity.java:7973)在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)在android.app.ActivityThread.performLaunchActivity(ActivityThreads.java:3329)在android.app.ActivityThread.handleLaunchActivity(ActivityThreads.java:3500)在android.app.servertransaction.LaunchActivityItem.exexecute(LaunchActivityItem.java:83)在android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)在android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)在android.app.ActivityThread$H.handleMessage(ActivityThreads.java:2049)在android.os.Handler.dispatchMessage(Handler.java:106)在android.os.Looper.loop(Looper.java:223)在android.app.ActivityThread.main(ActivityThreads.java:7523)位于java.lang.reflect.Method.ioke(本机方法)网址:com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)网址:com.android.internal.os.ZygoteInit.main(ZygoteNit.java:941)引起原因:com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException:使用MapView需要在膨胀或创建视图之前调用Mapbox.getInstance(Context Context,String accessToken)。使用Mapbox服务时,访问令牌参数是必需的。请访问https://www.mapbox.com/help/create-api-access-token/了解如何创建。本指南中的更多信息https://www.mapbox.com/help/first-steps-android-sdk/#access tokens。网址:com.mapbox.mapboxsdk.maps.MapView.initialize(MapView.java:136)网址:com.mapbox.mapboxsdk.maps.MapView.(MapView.java:112)…还有30个

我很抱歉我的英语不好。谢谢你的帮助。

Mapbox.getInstance()不适用于我的

将此应用于您的mapview xml文件

app:mapbox_resourcesAccessToken="string/MapsToken";

<com.mapbox.maps.MapView xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="40.7128"
mapbox:mapbox_cameraTargetLng="-74.0060"
app:mapbox_resourcesAccessToken="@string/MapsToken"
mapbox:mapbox_cameraZoom="9.0" />

相关内容

  • 没有找到相关文章

最新更新