react-native-maps: Unable to resolve Gradle dependencies

Is this a bug report?

Yes

Have you read the Installation Instructions?

Yes

Environment

react-native: 0.57.4 react: 16.6.0-alpha.8af6728 react-native-maps: 0.23.0

Target Platform: Android 9 Emulator, Nexus 5 X

Steps to Reproduce

  1. Follow the installation guide to configure the global settings.gradle and app’s build.gradle
  2. Hit the Android Studio Gradle’s Sync now button

Expected Behavior

I expect the react-native-maps project to be included in the main project and all its dependencies to get resolved by Gradle itself.

Actual Behavior

Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-compat:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-annotations:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-utils:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-ui:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-fragment:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-annotations:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-utils:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-fragment:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-compat:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-ui:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-compat:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-utils:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-ui:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-fragment:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-annotations:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-compat:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-annotations:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-core-utils:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-core-ui:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-fragment:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-annotations:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-core-utils:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-fragment:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-compat:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-core-ui:27.1.1.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-compat:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-core-utils:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-core-ui:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-fragment:25.2.0.
Open File
Show Details


Unable to resolve dependency for ':react-native-maps@release/compileClasspath': Could not resolve com.android.support:support-annotations:25.2.0.
Open File
Show Details

Reproducible Demo

My rootProject variable versions are

ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
        googlePlayServicesVersion = "11.8.0"
        androidMapsUtilsVersion = "0.5+"
    }

To reproduce the issue i have placed the above piece of code in my root build.gradle and have followed the installation guide for Android step by step.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 25 (3 by maintainers)

Most upvoted comments

The issues are related to other packages you include in the project.

all its dependencies to get resolved by Gradle itself

can’t be done due to that different supportLibVersion for different project make you have it resolved manually.

We can help, but I need a MCVE to checkout and see the problem.

P.S. @rborn @christopherdro I think moving such questions to SO and keeping here only real bugs could definitely help supporting the project.

@alvelig if this can help I’m sharing my app build.gradle and global build.gradle along with the way I was able to solve the dependency resolving issue manually.

build.gradle (app)

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.example.android"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-svg')
    compile project(':rn-fetch-blob')
    compile project(':react-native-firebase')
    compile project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules

    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.7"
    implementation "com.google.firebase:firebase-auth:16.1.0"
    implementation "com.google.firebase:firebase-database:16.0.6"

    // React native fetch blob
    implementation project(':rn-fetch-blob')

    // React native maps
    implementation project(':react-native-maps')

    // React native svg
    implementation project(':react-native-svg')
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply plugin: 'com.google.gms.google-services'

build.gradle (project)

buildscript {
    ext {
        buildToolsVersion = "28.0.2"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "15.0.1"
        androidMapsUtilsVersion = "0.5+"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

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


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

In order to solve the issue I had to use this configuration, as suggested by @JosefBlattler

ext {
        buildToolsVersion = "28.0.2"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "15.0.1"
        androidMapsUtilsVersion = "0.5+"
    }

along with adding this line to the end of react-native-maps build.gradle in the dependencies declaration

dependencies {
  def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_VERSION)
  // Variable lookup order : googlePlayServicesMapsVersion > googlePlayServicesVersion > DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION
  def googlePlayServicesMapsVersion = safeExtGet('googlePlayServicesMapsVersion', safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION))
  def androidMapsUtilsVersion = safeExtGet('androidMapsUtilsVersion', DEFAULT_ANDROID_MAPS_UTILS_VERSION)

  compileOnly "com.facebook.react:react-native:+"
  implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
  implementation "com.google.android.gms:play-services-maps:$googlePlayServicesMapsVersion"
  implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

  // ⬇️This line made Gradle sync successfully
  implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
}

Hope this can help!

This issue has been fixed for me also by adding this line into the react-native-maps 's build.gradle file

important : what I didn’t catch immediately is that this line should be added directly in the node_modules/react-native-maps/lib/android/build.gradle

Thanks @michaelsinatra !

dependencies {
  def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_VERSION)
  // Variable lookup order : googlePlayServicesMapsVersion > googlePlayServicesVersion > DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION
  def googlePlayServicesMapsVersion = safeExtGet('googlePlayServicesMapsVersion', safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION))
  def androidMapsUtilsVersion = safeExtGet('androidMapsUtilsVersion', DEFAULT_ANDROID_MAPS_UTILS_VERSION)

  compileOnly "com.facebook.react:react-native:+"
  implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
  implementation "com.google.android.gms:play-services-maps:$googlePlayServicesMapsVersion"
  implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

  // ⬇️This line made Gradle sync successfully
  implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
}

OK, a spend so much time for a solution, and find this: In your root android folder, open build.gradle and paste this in maven:

subprojects {
                project.configurations.all {
                    resolutionStrategy.eachDependency { details ->
                        if (details.requested.group == 'com.android.support'
                                && details.requested.name == 'support-v4') {
                            details.useVersion '28.0.0'
                        }
                    }
                }
            }

should be something like this:

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
            subprojects {
                project.configurations.all {
                    resolutionStrategy.eachDependency { details ->
                        if (details.requested.group == 'com.android.support'
                                && details.requested.name == 'support-v4') {
                            details.useVersion '28.0.0'
                        }
                    }
                }
            }

        }
    }
}

This work for me, I hope for you too

It works:

    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "15.0.1"
        androidMapsUtilsVersion = "0.5+"
    }

Este problema foi corrigido para mim também adicionando esta linha no arquivo build.gradle do react-native-maps.

important: o que eu não entendi imediatamente é que essa linha deve ser adicionada diretamente no node_modules / react-native-maps / lib / android / build.gradle

Obrigado @michaelsinatra !

dependencies {
  def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_VERSION)
  // Variable lookup order : googlePlayServicesMapsVersion > googlePlayServicesVersion > DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION
  def googlePlayServicesMapsVersion = safeExtGet('googlePlayServicesMapsVersion', safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION))
  def androidMapsUtilsVersion = safeExtGet('androidMapsUtilsVersion', DEFAULT_ANDROID_MAPS_UTILS_VERSION)

  compileOnly "com.facebook.react:react-native:+"
  implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
  implementation "com.google.android.gms:play-services-maps:$googlePlayServicesMapsVersion"
  implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

  // ⬇️This line made Gradle sync successfully
  implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
}

Você resolveu o meu problema! Obrigado

Hi @michaelsinatra thanks for providing this information. I added this line in my node_modules and it works again. So I create also small PR #2702 based on this. Maybe some of you can also verify that this PR works also for you?!

Thanks

@truongluong1314520 that’s fine, it’s a deprecation warning that has already a PR in works https://github.com/react-native-community/react-native-maps/pull/2740

But it should work for now without any problem. Thank you for testing 🤗

I am getting this error

Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 

When I change to @michaelsinatra solution, any thoughts?

Sorry @rborn, it was my mistake. I tested with the master version and it worked perfect. Thanks!

I hope you know that you are a lifesaver @michaelsinatra

Hi @rborn , I try this link github:react-native-community/react-native-maps#master and everything seem to work find except there is a warning:

Screenshot_1552564819

@truongluong1314520 this should be fixed in #https://github.com/react-native-community/react-native-maps/pull/2720 can you test with master please?

Any above solution doesn’t work at all. “react-native”: “^0.58.4” “react”: “16.6.3”, “react-native-maps”: “0.22.0”