Gradle play-services aar依赖不起作用

时间:2016-06-07 20:04:12

标签: java android android-studio gradle google-play-services

我正在编写一个java jar 库。我只想为gradle的项目添加play-services依赖项。我的gradle构建脚本:

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同步完成并且android studio告诉所有确定但是当我尝试构建时:

  

错误:包com.google.android.gms.ads不存在

已安装Google支持存储库和库。

SDK MANAGER SCREENSHOT

Android studio gradle部分: gradle screenshot

我的gradle版本2.13。 我还使用了最新的gradle候选版本。什么都没有。

1 个答案:

答案 0 :(得分:0)

问题在于gradle脚本。如果您想构建 aar 依赖关系,则需要使用gradle插件'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'