Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve Gradle dependencies #2695

Closed
michaelsinatra opened this issue Feb 13, 2019 · 25 comments
Closed

Unable to resolve Gradle dependencies #2695

michaelsinatra opened this issue Feb 13, 2019 · 25 comments

Comments

@michaelsinatra
Copy link

michaelsinatra commented Feb 13, 2019

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.

@luisfuertes
Copy link

luisfuertes commented Feb 13, 2019

It works:

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

@JosefBlattler
Copy link

JosefBlattler commented Feb 13, 2019

For me, works in android P:
`
ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "15.0.1"
androidMapsUtilsVersion = "0.5+"

}

`

But crash when I add Polyline.

@AresVampire
Copy link

I am facing the same issue.

@alvelig
Copy link
Contributor

alvelig commented Feb 18, 2019

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.

@AresVampire
Copy link

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

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

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

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

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

ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-annotations:28.0.0.
Show Details
Affected Modules: react-native-maps

ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-compat:28.0.0.
Show Details
Affected Modules: react-native-maps

ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-utils:28.0.0.
Show Details
Affected Modules: react-native-maps

ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-fragment:28.0.0.
Show Details
Affected Modules: react-native-maps

ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-core-ui:28.0.0.
Show Details
Affected Modules: react-native-maps

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

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

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

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

ERROR: Unable to resolve dependency for ':react-native-maps@debug/compileClasspath': Could not resolve com.android.support:support-annotations:26.1.0.
Show Details
Affected Modules: react-native-maps

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

WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Affected Modules: app

@AresVampire
Copy link

Any above solution doesn't work at all.
"react-native": "^0.58.4"
"react": "16.6.3",
"react-native-maps": "0.22.0"

@michaelsinatra
Copy link
Author

michaelsinatra commented Feb 18, 2019

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!

@jerolimov
Copy link
Contributor

jerolimov commented Feb 20, 2019

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

@alvelig alvelig closed this as completed Feb 21, 2019
@grifotv
Copy link
Contributor

grifotv commented Mar 11, 2019

App was crashing in Android 9. This fixed for me #2695 (comment)

@LuongTruong
Copy link

Hi guys, I am here to verify that the solution of @michaelsinatra save my life. I am using the react-native 0.59. What I need to do is simple add the magic line:

implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

@rborn
Copy link
Collaborator

rborn commented Mar 14, 2019

@truongluong1314520 this should be fixed in ##2720 can you test with master please?

@LuongTruong
Copy link

Hi @rborn , you mean I just need to npm install react-native-maps again? Or I need a specific link?

@LuongTruong
Copy link

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

@rborn
Copy link
Collaborator

rborn commented Mar 14, 2019

@truongluong1314520 that's fine, it's a deprecation warning that has already a PR in works #2740

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

@guillaumegustin
Copy link

guillaumegustin commented Mar 14, 2019

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}"
}

@seongminchoob
Copy link

I hope you know that you are a lifesaver @michaelsinatra

@ebnersilva
Copy link

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

@nfgutierrezp
Copy link

I used the solution of @michaelsinatra and worked well for 32-bit devices. However, app keeps stopping when rendering MapView in 64-bit devices. I have tested it in a Google Pixel and in android emulator.

@rborn
Copy link
Collaborator

rborn commented Mar 22, 2019

@nfgutierrezp did you test with the last master from github?
And if yes, could you open a new issue with some logs from the adb-logcat to see why/where is crashing?

Thank you

@nfgutierrezp
Copy link

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

@MauriPastorini
Copy link

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?

@IgnacioGalliano
Copy link

IgnacioGalliano commented Apr 12, 2019

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

@SirCameron
Copy link

@IgnacioGalliano King of town!

@jingfreeks
Copy link

there is no problem when I run on the debug mode however during the release mode it suddenly crash after compiling, when I check on the adb logcat it shows

s is not a function. (In 's()', 's' is 3)

@dkdurgesh
Copy link

add in lib/android/build.gradle for maps

def supportLibVersion = safeExtGet('supportLibVersion', '28.0.0')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests