首页 > 解决方案 > 在android studio中安装Mapbox的问题

问题描述

嗨,我尝试将 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>

也许这张图片有更多帮助 在此处输入图像描述

标签: androidgis

解决方案


简单,因为你复制 xmlns:android="http://schemas.android.com/apk/res/android" 只是删除重复然后运行它..

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:mapbox="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">

推荐阅读