[英]Gradle play-services aar dependency not work
I am writing a java jar library. 我正在编写一个Java jar库。 I just want to add play-services dependency for gradle's project.
我只想为gradle的项目添加play-services依赖项。 My gradle build script:
我的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 sync completes good and android studio tells that all ok but when I try to build: Gradle同步完成得很好,android studio告诉一切正常,但是当我尝试构建时:
error: package com.google.android.gms.ads does not exist
错误:包com.google.android.gms.ads不存在
Google support repository and library are installed. Google支持存储库和库已安装。
SDK MANAGER SCREENSHOT SDK管理员画面
Android studio gradle section: gradle screenshot Android Studio Gradle部分: gradle屏幕截图
My gradle version 2.13. 我的gradle版本2.13。 Also I used the latest gradle release candidate.
我也使用了最新的gradle版本候选。 Nothing.
没有。
The problem was with the gradle script. 问题出在gradle脚本上。 If you want to build the aar dependency you need to use gradle plugin 'com.android.library' .
如果要构建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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.