maps: React-native Android build fails with: Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1.

Describe the bug

I have a very basic react-native app that builds and runs perfectly in iOS. When I build it in Android Studio, the result is:

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1.
     Required by:
         project :app > project :react-native-mapbox-gl_maps
      > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1.
         > Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.7.1/mapbox-android-sdk-9.7.1.pom'.
            > Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.7.1/mapbox-android-sdk-9.7.1.pom'. Received status code 403 from server: Forbidden
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.14.0.
     Required by:
         project :app > project :react-native-mapbox-gl_maps
      > Could not resolve com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.14.0.
         > Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-plugin-localization-v9/0.14.0/mapbox-android-plugin-localization-v9-0.14.0.pom'.
            > Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-plugin-localization-v9/0.14.0/mapbox-android-plugin-localization-v9-0.14.0.pom'. Received status code 403 from server: Forbidden
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1.
     Required by:
         project :app > project :react-native-mapbox-gl_maps > com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0
         project :app > project :react-native-mapbox-gl_maps > com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0
      > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1.
         > Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.7.1/mapbox-android-sdk-9.7.1.pom'.
            > Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.7.1/mapbox-android-sdk-9.7.1.pom'. Received status code 403 from server: Forbidden

The build.gradle file is:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
        rnmbglMapboxLibs = {
            implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1'
            implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.8.0'
            implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.8.0'
            implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0'
        }

        rnmbglMapboxPlugins = {
            implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0'
            implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.14.0'
            implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0'
        }
    }
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        maven { url 'https://www.jitpack.io' }
        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 = 'token removed'
            }
        }
    }
}

Versions (please complete the following information):

  • Platform: Android
  • Dev OS: macOS 12.0.1
  • react-native-mapbox-gl Version 8.50
  • React Native Version 0.66

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

Anyone succeded in building an app on Android with MapBox ? We’ve been stuck on this issue for a few weeks, seems odd to me that it can’t be built.

I think I am having similar issues where I can’t get dependencies from bintray. The build consistently fails and has failed for the past month for me all related to bintray. I haven’t tried the example directly as that won’t do me much good. I have used the build.gradle with no luck. It’s trying to pull in dependencies from bintray and bintray is unaccessible for me and has been for a while. Any advice?

I copied the build.gradle from the mapbox example to my sample app build.gradle, and then my sample app worked with a few tweeks. Specifically, I had to change the minSDK to 26, and in ReactNativeFlipper.java, I had to change the variable “networkFlipperPlugin” to final. Now I will test my actual app. Thank you for your help.