嗨,我尝试将Map Box与Android Studio结合使用以学习如何构建GIS应用。我遵循本教程https://www.mapbox.com/install/android/
但是,当我尝试测试安装或某些示例时,出现以下错误。
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
编译--legacy \
-o \
C:\ Users \ Vassilis \ AndroidStudioProjects \ mapBox_test_nbg \ app \ build \ intermediates \ res \ merged \ debug
\
C:\ Users \ Vassilis \ AndroidStudioProjects \ mapBox_test_nbg \ app \ src \ main \ res \ layout \ activity_main.xml
守护程序: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>
也许那个形象有帮助
最佳答案
您必须更改mapbox_styleUrl
值。
mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
代替
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v11"
但是这种样式的StreetBox-v10和v11的MapBox目前在Android上不可用。
还要将此属性添加到您的mapBox xml中
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
最后,您的mapbox必须像这样
<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"
/>
关于android - 在Android Studio中安装Mapbox的问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53985056/