3

When I want to install Google play services 15.0.2 (because 15.0.0 create a dexing error I don't know why) I have these errors from gradle :

Failed to resolve: com.google.android.gms:play-services-location:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog


Failed to resolve: com.google.android.gms:play-services-basement:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog


Failed to resolve: com.google.android.gms:play-services-tasks:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog

But I've never put these dependencies in any build.gradle. If I want to install with the install button, I have the error : Could not find dependency

This is my build.gradle file :

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION             = 25
def DEFAULT_BUILD_TOOLS_VERSION             = "25.0.2"
def DEFAULT_TARGET_SDK_VERSION              = 25
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "15.0.2"

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? 
project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion project.hasProperty('buildToolsVersion') ? 
project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 
project.hasProperty('buildToolsVetargetSdkVersionrsion') ? 
project.buildToolsVersion : DEFAULT_TARGET_SDK_VERSION
    versionCode 1
    versionName "1.0"
}
}

repositories {
mavenCentral()
}

dependencies {
    def googlePlayServicesVersion = 
project.hasProperty('googlePlayServicesVersion') ? 
project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.facebook.react:react-native:+'
    compile "com.google.firebase:firebase-core:$googlePlayServicesVersion"
    compile "com.google.firebase:firebase-messaging:$googlePlayServicesVersion"
    compile 'me.leolin:ShortcutBadger:1.1.17@aar'
}

EDIT : I succeeded to solve my problem. Actually, I had a multidex script in my parent build.gradle which force updated all my com.gms.google to 15.0.2 but as you said, google play services don't have 15.0.2. I just removed this script and it worked

Psyycker
  • 317
  • 4
  • 16
  • instead of importing all google services , that causes dex error because of the quantity of methods, i would suggest just implementing the ones you will use in your app – Gastón Saillén May 10 '18 at 17:04
  • Possible duplicate of [Compilation failed to complete:Program type already present: com.google.android.gms.internal.measurement.zzabn](https://stackoverflow.com/questions/50149266/compilation-failed-to-completeprogram-type-already-present-com-google-android) – Peter Haddad May 10 '18 at 17:11
  • 1
    See this blog post: https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html – Bob Snyder May 10 '18 at 20:31
  • did you manage tofind a solution @Psyycker? – Levi Moreira May 10 '18 at 23:55
  • I finally could resolve my problem, see edit to see how I did. ADM answer was usefull to understand why I could not download google play services 15.0.2 – Psyycker May 11 '18 at 12:18

1 Answers1

2

Firebase libraries now have independent versions, as opposed to the same version they shared before. See here. So this is working for now, but it might be different in the future:

implementation "com.google.firebase:firebase-core:$googlePlayServicesVersion"
implementation "com.google.firebase:firebase-messaging:$googlePlayServicesVersion"

And more importantly, firebase libs no longer have the same version as the google play services ones, there is no version 15.0.2 for play services libraries such as location, see here, the latest is 15.0.0.

My advice is to define each library individually.

To fix you problem change this :

def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "15.0.0"

and this:

implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-messaging:15.0.2"
ADM
  • 20,406
  • 11
  • 52
  • 83
Levi Moreira
  • 11,917
  • 4
  • 32
  • 46