2

I have included cordova-plugin-firebase plugin into my project and having difficult with build on Android (ios is ok).

$ cordova plugin add cordova-plugin-firebase --save $ ionic cordova platform add android open android studio - synch gradle then below error appear

Error:Could not find play-services-base.jar (com.google.android.gms:play-services-base:15.0.1).
Searched in the following locations:
    https://jcenter.bintray.com/com/google/android/gms/play-services-base/15.0.1/play-services-base-15.0.1.jar

enter image description here

FYI, here are some project details

Im using ionic version 1
"cordova-android": "~6.3.0",
in build.gradle: classpath 'com.android.tools.build:gradle:2.2.3'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
    compile "com.android.support:support-v4:24.1.1+"
    compile "com.google.gms:google-services:+"
    compile "com.google.android.gms:play-services-tagmanager:+"
    compile "com.google.firebase:firebase-core:+"
    compile "com.google.firebase:firebase-messaging:+"
    compile "com.google.firebase:firebase-crash:+"
    compile "com.google.firebase:firebase-config:+"
    compile "com.google.firebase:firebase-perf:+"
    compile "com.android.support:appcompat-v7:23+"
    compile "com.onesignal:OneSignal:3.9.1"
    // SUB-PROJECT DEPENDENCIES END
}

in the Android SDK Manager -> SDK Tools. Google Play Services version 49 is installed https://imgur.com/a/qR29lbL

this is my build.gradle file gist.github.com/axilaris/39a22849a649c60bcce079b67d4bb638

How can I solve this for android ?

Axil
  • 3,606
  • 10
  • 62
  • 136
  • What is your tools build gradle version? I think you should add google() in your project's root build.gradle -> buildscript&allprojects->repositories{}. – DomonLee Jun 20 '18 at 07:56
  • Im not sure what you mean, i added some info above. it has this: classpath 'com.android.tools.build:gradle:2.2.3' – Axil Jun 20 '18 at 07:58
  • I think it is a maven repo issue. the play-services-base.jar should be download in google maven not in the jcenter. perhapse you can add `maven { url 'https://maven.google.com' }` instead `google()`. – DomonLee Jun 20 '18 at 08:01
  • this is my build.gradle. https://gist.github.com/axilaris/39a22849a649c60bcce079b67d4bb638 I think its the same as what you mentioned. – Axil Jun 20 '18 at 08:05
  • is it something to do with this dependencies - compile "com.google.gms:google-services:+" – Axil Jun 20 '18 at 09:40
  • can you specify your cordova-android version? Also have you installed google play services in sdk manager? – Suraj Rao Jun 23 '18 at 10:42
  • "cordova-android": "~6.3.0". i think google play services is not installed in sdk manager. https://i.imgur.com/jx08LfG.png let me try and get it installed and update if it works – Axil Jun 23 '18 at 16:49
  • it doesnt work. still has the same error: Error:Could not find play-services-base.jar (com.google.android.gms:play-services-base:15.0.1) – Axil Jun 24 '18 at 05:12
  • Can you also check in the SDK Manager if the `Google Repository` is installed? – code Jun 24 '18 at 05:20

1 Answers1

4

The answer can be found here:

Gradle build tool cannot find play-services-tasks.aar? Why?

https://issuetracker.google.com/issues/80362794

The fix is to put google url above jcenter() in your repository list in gradle. Here's the issue: https://issuetracker.google.com/issues/80362794

Basically, below was my fix to work in build.gradle

buildscript {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()

    }

    // Switch the Android Gradle plugin version requirement depending on the
    // installed version of Gradle. This dependency is documented at
    // http://tools.android.com/tech-docs/new-build-system/version-compatibility
    // and https://issues.apache.org/jira/browse/CB-8143
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()

    }
}
Axil
  • 3,606
  • 10
  • 62
  • 136