![](/img/trans.png)
[英]Xamarin.Android Google Play Services dependency via AAR Binding
[英]Gradle play-services aar dependency not work
我正在编写一个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支持存储库和库已安装。
Android Studio Gradle部分: gradle屏幕截图
我的gradle版本2.13。 我也使用了最新的gradle版本候选。 没有。
问题出在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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.