0

I am writing a java jar library. I just want to add play-services dependency for gradle's project. My gradle build script:

Properties local = new Properties()
local.load(project.file('local.properties').newDataInputStream())

ext {

    gdxVersion = '1.9.2';
    sdkPath = local.getProperty("sdk.dir")
}

repositories {

    maven { url "$sdkPath\\extras\\google\\m2repository\\" }
    maven { url "$sdkPath\\extras\\android\\m2repository\\" }

    maven { url "https://oss.sonatype.org/content/repositories/releases/" }

    mavenCentral()
}

apply plugin: 'java'
apply plugin: 'idea'

buildDir = 'gen'
libsDirName = '../bin'

sourceCompatibility = 1.8

sourceSets {

     main {

         java {

             srcDir 'src'
         }
     }
}

dependencies {

    compile "com.google.android.gms:play-services-ads:9.0.2";
    compile "com.google.android:android:4.1.1.4"
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
}

clean {

    delete fileTree(project.libsDir)
}

Gradle sync completes good and android studio tells that all ok but when I try to build:

error: package com.google.android.gms.ads does not exist

Google support repository and library are installed.

SDK MANAGER SCREENSHOT

Android studio gradle section: gradle screenshot

My gradle version 2.13. Also I used the latest gradle release candidate. Nothing.

  • This looks similar to [this thread](http://stackoverflow.com/questions/20403136/error-package-com-google-android-gms-ads-does-not-exist) – ReyAnthonyRenacia Jun 08 '16 at 09:26
  • Play-services.jar was deleted from android sdk. Google has divided all packages of the framework by aar packages and put them to the local maven repository(google support repository). Gradle don't want to take dependecies from the aar libs but his syncronization is OK. – TrueGameover Jun 08 '16 at 10:11

1 Answers1

0

The problem was with the gradle script. If you want to build the aar dependency you need to use gradle plugin 'com.android.library'.

buildscript {

    repositories {

        maven { url "https://oss.sonatype.org/content/repositories/releases/" }

        mavenCentral()
    }

    dependencies {

        classpath "com.android.tools.build:gradle:2.1.2"
    }
}

apply plugin: 'com.android.library'