MapBox 的布局编辑器渲染错误
Layout Editor Render error with MapBox
尝试在 Android Studio 中使用布局编辑器时出现以下错误:
Rendering Problems The following classes could not be instantiated:
- com.mapbox.mapboxsdk.maps.widgets.MyLocationView
代码运行良好,显示了地图。严格来说这是布局编辑器的问题。
SSCCE Github:
https://github.com/emnrd-ito/LayoutEditorRenderProblem
(但请注意,为了 运行 您需要在 access_token
中提供 Map Box 访问令牌的代码。)
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="testdemo.com.layouteditorrenderproblem.MainActivity">
<!-- NYC Union Square: 40.73581, -73.99155 -->
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
mapbox:center_latitude="40.73581"
mapbox:center_longitude="-73.99155"
mapbox:style_url="mapbox://styles/mapbox/streets-v9"
mapbox:zoom="17" />
</RelativeLayout>
编辑:
更多信息基于@cammace 的回答:
原始依赖项:
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.1@aar') {
transitive = true
}
compile('com.mapbox.mapboxsdk:mapbox-android-services:1.3.1@aar') {
transitive = true
}
更改为:
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.1@aar')
仍然出现错误。
然后改为:
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.0-beta.1@aar')
我收到如下错误:
No resource found that matches the given name (at textColor
with
value @color/black`).
<TextView
android:text="@string/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/about_app_name"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="@dimen/text_size_xxl"/>
您的项目似乎使用了我们 SDK 的过时版本。这个问题应该在最新的稳定版和测试版中得到解决。请升级到 4.2.1
或 5.0.0-beta.1
,看看是否可以解决问题。
尝试在 Android Studio 中使用布局编辑器时出现以下错误:
Rendering Problems The following classes could not be instantiated:
- com.mapbox.mapboxsdk.maps.widgets.MyLocationView
代码运行良好,显示了地图。严格来说这是布局编辑器的问题。
SSCCE Github:
https://github.com/emnrd-ito/LayoutEditorRenderProblem
(但请注意,为了 运行 您需要在 access_token
中提供 Map Box 访问令牌的代码。)
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="testdemo.com.layouteditorrenderproblem.MainActivity">
<!-- NYC Union Square: 40.73581, -73.99155 -->
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
mapbox:center_latitude="40.73581"
mapbox:center_longitude="-73.99155"
mapbox:style_url="mapbox://styles/mapbox/streets-v9"
mapbox:zoom="17" />
</RelativeLayout>
编辑: 更多信息基于@cammace 的回答:
原始依赖项:
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.1@aar') {
transitive = true
}
compile('com.mapbox.mapboxsdk:mapbox-android-services:1.3.1@aar') {
transitive = true
}
更改为:
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.1@aar')
仍然出现错误。
然后改为:
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.0-beta.1@aar')
我收到如下错误:
No resource found that matches the given name (at
textColor
with value @color/black`).
<TextView
android:text="@string/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/about_app_name"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="@dimen/text_size_xxl"/>
您的项目似乎使用了我们 SDK 的过时版本。这个问题应该在最新的稳定版和测试版中得到解决。请升级到 4.2.1
或 5.0.0-beta.1
,看看是否可以解决问题。