当我试图将 Mapbox 导航 SDK 应用到我的项目中时,一直出现“找不到属性 mapbox_styleUrl”的错误。
我想这可能与 Map SDK 迁移到 7.0.0 版本有关,他们删除了 mapbox_styleUrl XML 属性,但我无法找到解决方法。
我代码中没有使用 styleUrl。我保留了地图布局的默认样式,并在 onMapReady 中设置它。
以下是完整的错误信息:
Android resource linking failed
Output: C:\Users\Jonas\.gradle\caches\transforms-1\files-1.1\mapbox-android-navigation-ui-0.26.0.aar\0ea5c6919c35d65de36f46fe7fce49d7\res\layout\navigation_view_layout.xml:10: error: attribute mapbox_styleUrl (aka com.fishdev.planmyrun:mapbox_styleUrl) not found.
error: failed linking file resources.
完整的build.gradle
文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.fishdev.planmyrun"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Mapbox dependencies
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.0.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.4.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.26.0'
我的布局中的MapView:
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="50.87485515"
mapbox:mapbox_cameraTargetLng="4.707931288875566"
mapbox:mapbox_cameraZoom="11"
/>