Open abdoul-kader1 opened 9 months ago
Seems you didn't follow the instruction to correctly set your MapBox access token hence you are getting a 401 unauthorized error
I followed the instructions, I created an xml file in the resources of my kotlin folder
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="mapbox_access_token" translatable="false" tools:ignore="UnusedResources">my public token</string>
</resources>
then I added the permissions in androidMinifdest
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
then in the gradle.properties I added my secret token
org.gradle.jvmargs=-Xmx4G
android.useAndroidX=true
android.enableJetifier=true
MAPBOX_DOWNLOADS_TOKEN=my secret token
and finally I changed the FlutterActivity to FlutterFragmentActivity in the MainActivity file in my kotlin folder and add "implementation platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")android/app/build.gradle" in the build.gradle located in the app folder of the native android folder
package com.example.oblack_drive
//import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {
}
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.example.oblack_drive"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.oblack_drive"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")
}
@eopeter ?
Please follow the instruction on how to properly set up your mapbox access and download tokens
@eopeter I configured the public and private tokens, for the public scope all the boxes were checked since it is the default token, now for the private scope I only checked the download box
Follow the instruction on the ReadMe on how to set the token. You are getting a 401 which means you didn't set the token properly
I also followed the configuration instructions for Android I even put the steps higher in the conversation. when I build the application for the first time I receive a ton of information in the console as well as the 401 message but when I do a hot reload I no longer have the 401 message but the other information from my console is displayed
Hello, thank you for your availability I was able to resolve the problem
How did you resolve it? Is there a step missing in the instruction that was not clear on how to setup your access token?
there was no problem with the token configuration but rather with how I used the MapBoxNavigationView widget. I called this widget without the properties or methods that allow me to start a navigation thinking that the package could show me just a map without starting the navigation, the absence of these properties or methods throws the 401 error
@abdoul-kader1 I have the same problem, can you tell me how you solved it? I'm going crazy!
Wait, I'm publishing a test usage demo on my GitHub
I suggest visiting the following example: https://github.com/codewithdarkwa/turn-by-turn-navigation-flutter
I followed the steps to display a map but I receive this information in my console :