应用程序在API 19中打开view.InflateException
时抛出MapBox
。这是错误:
12-06 11:59:22.057 2906-2906/com.example.sabith.doortracker E/UncaughtException: java.lang.RuntimeException: Unable to
start activity ComponentInfo{com.example.sabith.doortracker/com.example.sabith.doortracker.view.admin.WorkPolylineActivity}:
android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.mapbox.mapboxsdk.maps.MapView
at android.view.LayoutInflater.createView(LayoutInflater.java:621)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.sabith.doortracker.view.admin.WorkPolylineActivity.onCreate(WorkPolylineActivity.java:71)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.sabith.doortracker.view.admin.WorkPolylineActivity.onCreate(WorkPolylineActivity.java:71)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.VerifyError: com/mapbox/mapboxsdk/maps/widgets/MyLocationView
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
at android.view.LayoutInflater.inflate(LayoutInflater.java:462)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.mapbox.mapboxsdk.maps.MapView.initialise(MapView.java:125)
at com.mapbox.mapboxsdk.maps.MapView.<init>(MapView.java:102)
build.gradle:
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0@aar'
//Mapbox webkit Library
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.1@aar') {
transitive = true
}
layout.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:mapbox="http://schemas.android.com/apk/res-auto">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapViewPolyline"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
mapbox:mapbox_cameraZoomMin="6"
mapbox:mapbox_uiRotateGestures="false"/>
</RelativeLayout>
但是,应用程序在大于19的API上运行顺利。
请提出解决方案。
答案 0 :(得分:2)
OP问题已通过https://github.com/mapbox/mapbox-gl-native/pull/10579修复,并且即将发布的版本5.2.1
中可用。
与此同时,您可以使用包含修复程序的5.3.0-SNAPSHOT
版本对此进行测试。
要使用快照,您需要在根build.gradle
文件中添加快照存储:
allprojects {
repositories {
jcenter()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
}
在您的应用build.gradle
中,您需要将当前的依赖项替换为:
implementation(com.mapbox.mapboxsdk:mapbox-android-sdk:5.3.0-SNAPSHOT@aar) {
transitive = true
}
希望有所帮助!干杯!
答案 1 :(得分:0)
对于非快照版本,请使用:
repositories {
jcenter()
maven { url "http://oss.sonatype.org/content/repositories/" }
}