android - 在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>
解决方案
简单,因为你复制 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">
推荐阅读
- android - Gradle:发布ApkProductionRelease到内部测试
- python - TensorFlow 本地训练 LibCurl 错误代码 6(tf.estimator.train_and_evaluate() 错误)
- python - 如何创建一个接受命令并打印“$”提示以指示用户可以使用 while 循环输入命令的 shell 程序?
- c - C - 复制字符串数组
- c++ - C++ 在线程运行时按下箭头键
- xmlhttprequest - Gartic.io - 它是如何工作的?XHR 请求
- android - Android 构建错误:程序类型已存在:android.support.v7.app.**
- javascript - 为什么事件处理程序会在 Firefox 中引发错误?
- java - 哪个资源限定符用于 android 布局屏幕?
- firebase-cloud-messaging - 无需选择加入即可推送到网络