未能在IntelliJ Idea中用gradle解决:com.google.android.gms:play-services [英] Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

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

问题描述

我试图在IntelliJ Idea中将google play服务添加到我的libGDX项目中。我已在此处遵循设置指南:



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



任何想法都值得欢迎。



预先致谢!

解决方案

我刚刚用11.0.0替换了11.2.0版本,然后它似乎工作正常,所以必须意味着11.2.0不包含在最新的Android SDK。

因此,在与所有可用的分散文档拼搏之后,我纯粹偶然地达到了这个文档(我猜Google的索引不够高):
https://developers.google.com/android/guides/releases



我从那里引用:


Google Play服务11.2版本的亮点。 Google Play
服务依赖关系现在可通过maven.google.com获得


现在,即使这并不意味着它们不再与下载的SDK一起提供,似乎实际上是这种情况。



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

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



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

  allprojects {
...
存储库{
...
maven {urlhttps://maven.google.com /}
}
}

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

  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:play-services'我只使用'com.google.android.gms :play-services-ads'这就是我现在真正感兴趣的API。对于其他像这样的解决方案可能没有用处的其他特殊情况,本文可以提供一些更好的见解: https://developer.android.com/studio/build/multidex.html



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



就是这样。到目前为止,所有内容都会生成,我的游戏最终会显示Admob横幅广告。



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



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

然而,我希望我的经验对其他人有用。 / p>

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.

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

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