1

I need to import import com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions; in my app code, for that I need to implement com.mapbox.maps:android:10.2.0 in build.gradle module, but it fails.

Could someone tell me, why this gradle implement fails to resolve?

 implementation ('com.mapbox.maps:android:10.2.0'){
        exclude group: 'group_name', module: 'module_name'
    }

This is the error msg:

Failed to resolve: com.mapbox.maps:android:10.2.0

In stack trace it says: NotFound com.mapbox.maps:android:10.2.0

Show in Project Structure dialog Affected Modules: appenter image description here

build.gradle (project)

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://api.mapbox.com/downloads/v2/releases/maven'
            authentication{
                basic(BasicAuthentication)

            }
            credentials{
                username='mapbox'
                password= project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?:""
            }

        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

ERROR INFORMATION enter image description here

Khkhy
  • 142
  • 2
  • 10
  • Can you add your project level `build.gradle` – Nitish Dec 24 '21 at 04:51
  • Maybe you can show us error information of gradle building. – ruby6221 Dec 24 '21 at 08:09
  • Can you tell me where you found implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.0.0'? im following the map installation guide and theres no mention of this, only implementation 'com.mapbox.maps:android:10.2.0 – alfietap Dec 24 '21 at 12:05
  • @Nitish I updated, providing what you requested. Any idea why it is not working? – Khkhy Dec 24 '21 at 17:15
  • @alfietap - Here I guess: https://search.maven.org/artifact/com.mapbox.mapboxsdk/mapbox-android-sdk – Khkhy Dec 24 '21 at 17:38

1 Answers1

3

After a a few hours of research I came to find out how to properly set up Mapbox (10.0.2) on Android

IMO, this first bullet should solve the issue, otherwise keep going.

First, in settings.gradle -> as stated previously set mode to PREFERS.SETTINGS .

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
  repositories {
    google()
    mavenCentral()
    jcenter() // Warning: this repository is going to shut down soon
    maven {
        url 'https://api.mapbox.com/downloads/v2/releases/maven'
        authentication {
            basic(BasicAuthentication)
        }
        credentials {
            // Do not change the username below.
            // This should always be `mapbox` (not your username).
            username = "mapbox"
            // Use the secret token you stored in gradle.properties as the password
            password = MAPBOX_DOWNLOADS_TOKEN
        }
      }
    }
  }

Second, add the dependency as per usual to module-level build.gradle (not project level)

    implementation 'com.mapbox.maps:android:10.2.0'

Third, this is what my project-level build.gradle looks like.

 buildscript {
ext {
    compose_version = '1.2.0-alpha02'
}
repositories {
    google()
    mavenCentral()

}
dependencies {
    classpath 'com.android.tools.build:gradle:7.1.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

Last, in your gradle.property make sure you have

(GOOD)   MAPBOX_DOWNLOADS_TOKEN = SECRET_ACCESS_CODE
(DO NOT) MAPBOX_DOWNLOADS_TOKEN = "SECRET_ACCESS_CODE"
Koch
  • 555
  • 4
  • 15