Adil Ijaz
Adil Ijaz

Reputation: 352

How to solve Could not find com.mapbox.maps:android:10.16.0 react-native mapbox

I am working with react-native @rnmapbox/maps first time it is perfectly working in iOS devices but in Android is throwing errors while building the app.

The errors are following:

 What went wrong:
Could not determine the dependencies of task ':rnmapbox_maps:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':rnmapbox_maps:debugCompileClasspath'.
   > Could not find com.mapbox.maps:android:10.16.0.
     Required by:
         project :rnmapbox_maps
   > Could not find com.mapbox.mapboxsdk:mapbox-sdk-turf:6.11.0.
     Required by:
         project :rnmapbox_maps

I setup in my code in this way,

First I install the package *yarn add @rnmapbox/maps

then in android > build.gradle


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

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        RNMapboxMapsImpl = 'mapbox'
        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
        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 = project.properties['my-mapbox-key'] ?: ""
            }
        }
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
    }
}


But its not working.

REACT-NATIVE: 0.72.6 I am using.

Upvotes: 1

Views: 1064

Answers (2)

shiraz27
shiraz27

Reputation: 2636

Follow the official docs and have the required version at the top 10.16 or 11.*

https://github.com/rnmapbox/maps/blob/main/android/install.md https://github.com/rnmapbox/maps/blob/main/ios/install.md

Upvotes: 0

JovanGacic
JovanGacic

Reputation: 101

What worked for me - instead of having this:

 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 = project.properties['my-mapbox-key'] ?: ""
            }
        }

inside buildscripts.repositories, make sure to create a new object (or however you wanna call it) and put it under allProjects.repositories, like this:

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        RNMapboxMapsImpl = 'mapbox'
        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
    }
}

allprojects {
    repositories {
       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 = project.properties['my-mapbox-key'] ?: ""
            }
        }
    }
}

Also make sure you are providing the secret key properly.

Upvotes: 0

Related Questions