Reputation: 55
I keep getting the error "attribute mapbox_styleUrl not found" when trying to implement the Navigation SDK of Mapbox into my project. I think it has to do with the migration of the Map SDK to 7.0.0 where they removed the mapbox_styleUrl XML attribute, but I'm unable to find a way to fix this.
I'm not using the styleUrl in any of my code. I leave the map style in my layout default and set it in onMapReady.
This is the complete error:
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.
Complete 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'
}
My MapView in layout:
<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"
/>
Upvotes: 3
Views: 4292
Reputation: 21
make sure u are settig the content view to the correct layout
ie: my line on the set content view was set to mainActivity istead of MapsActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Mapbox.getInstance(MapsActivity.this, getString(R.string.mapbox_access_token));
setContentView(R.layout.activity_maps);
Upvotes: 0
Reputation: 951
I happened to come across the exact same issue today whilst migrating an Android app from Mapbox Android SDK 6.5.0
to 7.0.0
.
I too had no mapbox_styleUrl
usages in my code, so I spent a little time scratching my head before I noticed that the error references mapbox-android-navigation-ui-0.26.0
which appears to be utilising this attribute (removed in Mapbox Android SDK 7.0.0
). Taking a deeper look into the Mapbox Navigation Android repository, I noticed that the latest commit (from ~6 hours ago) of mapbox-android-navigation-ui
had brought everything up to date with the Mapbox Android SDK 7.0.0
.
Since these fixes had not been packaged in an official release as yet, I added the latest snapshot release to my project by updating my dependencies via Gradle:
repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.27.0-SNAPSHOT'
}
I sincerely hope that saves you a headache!
Upvotes: 2