无法解析:com.google.android.gms:play-services in IntelliJ Idea with gradle [英] Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

查看:43
本文介绍了无法解析:com.google.android.gms:play-services in IntelliJ Idea with gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 IntelliJ Idea 中将 google play 服务添加到我的 libGDX 项目中.我已按照此处的设置指南进行操作:

我使用的是 API 级别 26,但无论如何其他定义确实使用与 Android SDK 完全相同的目录.此外,我在这台笔记本电脑上根本没有安装任何其他 android SDK,所以毫无疑问 Idea 只使用那个和那个.

欢迎提出任何想法.

提前致谢!

解决方案

我刚刚用 11.0.0 替换了 11.2.0 版本,然后它似乎工作正常,所以这意味着 11.2.0 没有包含在最新的安卓 SDK.

因此,在与所有可用的分散文档苦苦挣扎之后,我纯粹是偶然地找到了这个文档(我猜它没有被 Google 索引得足够高):https://developers.google.com/android/guides/releases

我从那里引用:

<块引用>

Google Play 服务 11.2 版的亮点.谷歌播放服务依赖项现在可通过 maven.google.com 获得

现在,即使这不一定意味着它们不再适用于下载的 SDK,但事实似乎确实如此.

无论如何,将 google() 添加到我的 build.gradle 不起作用(未找到、未定义或其他任何...),所以我使用了一种不同的方法,我在本文档中引用了上一个:

https://developer.android.com/studio/build/dependencies.html#google-maven

我修改了我的 build.gradle 文件,将该行添加到所有项目/存储库,如下所示:

所有项目{...存储库{...maven { url "https://maven.google.com/"}}}

然后也在同一个 build.gradle 文件中的 android 部分:

project(":android") {...依赖{...编译 'com.google.android.gms:play-services-ads:11.2.0'}}

这两行足以使 Gradle 同步而不会出现问题.除了默认情况下已添加到我的 libGDX 项目中的插件之外,我不需要添加任何插件.

在那之后,我遇到了一些不同的错误,但没有关于 Gradle 或依赖项.简而言之,JFTR:

首先,我的 minSdkVersion 为 8.通过将其提高到 14 来解决.我想我可以不支持所有 14 以下的设备.

其次,我遇到了 dex 引用上限的问题.我以前从未遇到过这个问题,但也许您已经注意到我使用的解决方案:我只使用了 com.google.android.gms 而不是编译整个 'com.google.android.gms:play-services':play-services-ads' 这就是我现在真正感兴趣的 API.对于像这样的解决方案可能没有用的其他特定情况,本文档可以提供一些更好的见解:https://developer.android.com/studio/build/multidex.html

第三,即使在那之后我也得到了这个巨型"问题的描述和回答:https://stackoverflow.com/a/26248495/1160360

就是这样.到目前为止,一切都建立起来了,我的游戏终于显示了那些 Admob 横幅.

我花了几个小时来思考这个问题,这让我想知道我们最近使用的所有这些楼宇自动化系统是否值得它们增加的额外负载.

我的意思是,五年前我第一次必须将 Admob 添加到应用程序中时,我只需要下载一个 .jar 文件并将其放在我项目的目录中.这很明显,整个过程,从谷歌搜索如何在我的 android 项目中设置 Admob"到让我的应用程序显示 Admob 横幅只花了我几分钟.我要把它留在这里,因为这里不是进行这种辩论的地方.

尽管如此,我还是希望我自己的经验对其他人有帮助.

I'm trying to add google play services to my libGDX project in IntelliJ Idea. I've followed the setup guide here: https://developers.google.com/android/guides/setup

which looks pretty straightforward. I just added those lines to my build.gradle in the corresponding section, so things look now like:

project(":android") {
    apply plugin: "android"
    apply plugin: 'com.android.application'

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
        compile 'com.google.android.gms:play-services:11.2.0'
    }
}

Then I try to sync my gradle project in Idea just to get that "Failed to resolve" error.

Well, the setup guide also says "Be sure you update this version number each time Google Play services is updated", but the problem is that it seems nearly impossible to find that version number: my Google Play Services SDK version according to the Android SDK manager is "43", and so far I have been unable to correlate such "11.2.0" or whatever typical version string with the "43" version number. Not that the setup guide says nothing about that.

Anyway, I have tried a lot of things from the plethora of questions related to this to no avail. Specifically, I have to point out that I do have my Android SDK properly updated and I'm sure it is the one it's being used by Idea (I've already triple-checked this...):

I'm using the API level 26, but anyway the other defines do use the very same directory for the Android SDK. Moreover, I do NOT have any other android SDK installed at all in this laptop, so there's no question about Idea being using that one and that one only.

Any ideas are more than welcome.

Thanks in advance!

解决方案

I just replaced version 11.2.0 with 11.0.0 and then it seemed to work fine, so that had to mean that 11.2.0 wasn't included with the latest Android SDK.

So, after struggling with all the available scattered documentation, I reached this document by pure chance (I guess it is not indexed high enough by Google): https://developers.google.com/android/guides/releases

I quote from there:

Highlights from the Google Play services 11.2 release. Google Play services dependencies are now available via maven.google.com

Now, even when that shouldn't necessarily mean that they are not available with the downloaded SDK anymore, it seems that this is actually the case.

Anyway, adding google() to my build.gradle didn't work (not found, undefined, or whatever...), so I used a different approach that I found in this document referenced from the previous one:

https://developer.android.com/studio/build/dependencies.html#google-maven

I modified my build.gradle file adding that line to allprojects/repositories, as in:

allprojects {
...
    repositories {
...
        maven { url "https://maven.google.com/"}
    }
}

And then also in the android section in the same build.gradle file:

project(":android") {
...
    dependencies {
...
        compile 'com.google.android.gms:play-services-ads:11.2.0'
    }
}

Those two lines were enough to make Gradle sync without problems. I didn't need to add any plugins apart from the ones that are already added in my libGDX project by default.

After that, I got a few different errors, but none about Gradle or dependencies. In a brief, JFTR:

First, I had a minSdkVersion of 8. Solved by raising it to 14. I think I could live without supporting all those devices below 14.

Second, I had problems with the dex upper limit of references. I've never faced this problem before, but maybe you've already noticed the solution I used: instead of compiling the whole 'com.google.android.gms:play-services' I used only 'com.google.android.gms:play-services-ads' that's the API I'm actually interested right now. For those other particular cases where a solution like this may not be useful, this document could provide some better insight: https://developer.android.com/studio/build/multidex.html

Third, even after that I got this "jumbo" thing problem described and answered here: https://stackoverflow.com/a/26248495/1160360

And that's it. As of now, everything builds and my game does finally shows those Admob banners.

I've spent hours with this, thought, which makes me wonder if all these building automation systems we are using lately are worth the extra load they add.

I mean, the first time I had to add Admob to an app five years ago or so, I just had to download a .jar file and put it on a directory on my project. It was pretty obvious and the whole process, from googling "how to setup Admob in my android project" to have my app showing an Admob banner took me just a few minutes. I'm gonna leave it here, since this is not the place for such kind of debate.

Nonetheless, I hope my own experience is useful for someone else further.

这篇关于无法解析:com.google.android.gms:play-services in IntelliJ Idea with gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆