簡體   English   中英

MapBox的布局編輯器渲染錯誤

[英]Layout Editor Render error with MapBox

嘗試在Android Studio中使用布局編輯器時出現以下錯誤:

Rendering Problems The following classes could not be instantiated:
- com.mapbox.mapboxsdk.maps.widgets.MyLocationView

代碼工作正常,顯示了地圖。 嚴格來說,這是布局編輯器的問題。

Github上的SSCCE:
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')

我收到如下錯誤:

找不到與給定名稱匹配的資源(在textColor ,值為@ 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的過時版本。 此問題應在最新的穩定版和Beta版中解決。 請升級到4.2.15.0.0-beta.1 ,看看是否可以解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM