gpt4 book ai didi

java - Gradle Play-Services AAR依赖项不起作用

转载 作者:行者123 更新时间:2023-12-03 06:07:30 24 4
gpt4 key购买 nike

我正在编写一个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告诉一切正常,但是当我尝试构建时:

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



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

SDK MANAGER SCREENSHOT

Android Studio Gradle部分:
gradle screenshot

我的gradle版本2.13。
我也使用了最新的gradle版本候选。没有。

最佳答案

问题出在gradle脚本上。如果要构建依赖关系,则需要使用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'

关于java - Gradle Play-Services AAR依赖项不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37688329/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com