当前位置: 首页 > 知识库问答 >
问题:

在android studio中安装Mapbox存在的问题

爱博达
2023-03-14

嗨,我尝试在Android studio中使用Map Box来学习如何构建GIS应用程序。我遵循本教程https://www.mapbox.com/install/Android/但是当我试图测试html" target="_blank">安装或一些示例时,我收到以下错误。

Android资源编译失败输出:C:\users\vassilis\androidstudioprojects\mapbox_test_nbg\app\src\main\res\layout\activity_main.xml:3:错误:重复属性。

命令:C:\users\vassilis.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\efd9526a9f78532313c282340621c36b\aapt2-3.2.1-4818971-windows\AAPT2.exe compile-legacy\-O\c:\users\vassilis\androidstudioprojects\mapbox_test_nbg\app\build\res\mapbox_test_nbg\debug\c:\users\vassilis\androidstudio守护进程:AAPT2 aapt2-3.2.1-4818971-Windows守护进程#2

activity_main.xml的代码为:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:mapbox="http://schemas.android.com/apk/res-auto"
    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"
    tools:context=".MainActivity">

    <com.mapbox.mapboxsdk.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        mapbox:mapbox_cameraTargetLat="40.73581"
        mapbox:mapbox_cameraTargetLng="-73.99155"
        mapbox:mapbox_cameraZoom="11"
        mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v11"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="0dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

共有1个答案

桑睿识
2023-03-14

必须更改MAPBOX_STYLEURL值。

mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"

而不是

 mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v11"

但是这种streets-v10和v11风格的MapBox目前在Android上没有。

 app:layout_constraintEnd_toEndOf="parent"
 app:layout_constraintTop_toTopOf="parent"
 app:layout_constraintStart_toStartOf="parent"
 app:layout_constraintBottom_toBottomOf="parent"
<com.mapbox.mapboxsdk.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        mapbox:mapbox_cameraTargetLat="40.73581"
        mapbox:mapbox_cameraTargetLng="-73.99155"
        mapbox:mapbox_cameraZoom="11"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_street1"
        />
 类似资料: