如何使用 Gradle 构建在 Android Studio 中导入 com.google.android.gms.*? [英] How do I import com.google.android.gms.* in Android Studio using a Gradle build?

查看:81
本文介绍了如何使用 Gradle 构建在 Android Studio 中导入 com.google.android.gms.*?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照此处描述的程序进行操作:设置我点击了与 Gradle 同步项目"的小按钮.Gradle 和 Android Studio 似乎 可以找到所有内容,但实际上我无法使用 gms 代码.如果我尝试导入,我将获得 com.google.android.gms 的自动完成功能,但不会再进一步​​.我已经使用 Android SDK Manager 更新了所有包.

I have followed the procedure as described here : Setup I have clicked on the little 'Sync project with Gradle' button. Gradle and Android Studio seem to find everything but then I can't actually use the gms code. If I try to import, I will get autocomplete for com.google.android.gms but no further. I have updated all the packages with Android SDK Manager.

  • 我正在运行 Android Studio 0.4.2.
  • 我的 minSdk 设置为 9
  • 我的 build.gradle 包括编译 'com.google.android.gms:play-services:4.0.30'

就程序而言,我应该准备好编码,但它不起作用.有什么想法吗?

As far as the procedure is concerned I should be ready to code, but it just doesn't work. Any ideas?

我可以在分解的包目录中找到 ComGoogleAndroiddGmsPlayServices3265.aar 文件.在该文件中,我还找到了公共目录,并在其中找到了 GooglePlayServicesUtil.class(在我的应用程序中没有找到)

I can find the ComGoogleAndroiddGmsPlayServices3265.aar file in my exploded bundles directory. Inside of that file I also find the common directory and inside that I find the GooglePlayServicesUtil.class (which is what's not being found in my app)

我迷路了.

该问题并非特定于 Google Play 服务或 Android Studio.我尝试添加另一个库(HoloColorPicker)并得到相同的结果.但是,我能够将图书馆的资源添加到我的项目中!我能够将它们添加到我的 XML 布局中并在我的应用程序中查看它们.我能够与他们互动,他们工作得很好.当我试图在代码中引用它们时,问题再次出现.与 gms 的情况完全一样,我在尝试导入到实际类的点时有代码完成,但我无法在代码中声明该类.

The problem is not specific to Google Play Services OR Android Studio. I tried adding another library (HoloColorPicker) and had the same results. However, I was able to add the library's resources to my project! I was able to add them in my XML layouts and view them in my application. I was able to interact with them, they worked fine. The problem arose again when I tried to reference them in the code. Exactly like the case with gms, I had code completion when trying to import up to the point of the actual class, and I could not declare the class in the code.

我能够通过克隆和导入项目来使用该库.

I was able to use the library by cloning it and importing the project.

此外,这不是 Android Studio 的问题,因为在命令行上使用./gradlew clean build"会发生同样的事情

Also, this is not an Android Studio problem because the same thing happens on the command line with "./gradlew clean build"

推荐答案

这是 Android Studio 中的当前错误:https://code.google.com/p/android/issues/detail?id=64508 将于本周修复.

This is a current bug in Android Studio: https://code.google.com/p/android/issues/detail?id=64508 to be fixed this week.

解决方法是关闭项目,删除 .iml 文件和 .idea 项目,然后重新导入项目.

The workaround is to close the project, delete the .iml files and .idea project and re-import the project.

这篇关于如何使用 Gradle 构建在 Android Studio 中导入 com.google.android.gms.*?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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