错误包`com.google.android.gms...` 不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22262344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:44:01  来源:igfitidea点击:

Error package `com.google.android.gms...` doesn't exist

androidandroid-studioparse-platformgoogle-maps-android-api-2

提问by har07

I am new to Android development. I am learning to use Parse.com backend service and get stuck early on.

我是 Android 开发的新手。我正在学习使用 Parse.com 后端服务并很早就陷入困境。

I am following tutorialto create application that uses Google Maps Android API v2. What I've done :

我正在按照教程创建使用Google Maps Android API v2. 我所做的:

  1. download sample projectfrom parse
  2. Import AnyWall-android\Anywallfolder from downloaded project to Android Studio
  3. Rebuild project
  1. 从 parse下载示例项目
  2. AnyWall-android\Anywall从下载的项目导入文件夹到 Android Studio
  3. 重建项目

Then I get a bunch of errors here :

然后我在这里收到一堆错误:

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap.CancelableCallback;
import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

common, location, and mapshighlighted red. The question is how to resolve these errors?

common, location, 并以maps红色突出显示。问题是如何解决这些错误?

I appreciate any kind of help or direction (What should I check? Is it about missing library? If it is, what library should I add and where to get it?)

我感谢任何形式的帮助或指导(我应该检查什么?是否与缺少库有关?如果是,我应该添加什么库以及从哪里获取它?)

采纳答案by user4352520

Can't find the class com.google.android.gms.location.LocationClient (android)

找不到类 com.google.android.gms.location.LocationClient (android)

There is some problem with the last GPS lib. You have to use an older version than the latest(6.+). Try with an older version. I didn't see anything inside the doc deprecated or missing about the LocationClient.class...

最后一个 GPS 库存在一些问题。您必须使用比最新版本(6.+)更旧的版本。用旧版本试试。我在文档中没有看到有关 LocationClient.class 的任何内容已弃用或丢失...

compile 'com.google.android.gms:play-services:5.+'

编译'com.google.android.gms:play-services:5.+'

回答by Md Imran Choudhury

I think the best solution is, add compile API on your Gradle. services-locationhas this method.

我认为最好的解决方案是,在你的 Gradle 上添加 compile API。 services-location有这个方法。

 compile 'com.google.android.gms:play-services-maps:9.8.0'
 compile 'com.google.android.gms:play-services-location:9.8.0'

if you wish to include other services, please refer here: https://developers.google.com/android/guides/setup(scroll down)

如果您希望包含其他服务,请参考此处:https: //developers.google.com/android/guides/setup(向下滚动)

回答by marmor

Google Play Services is now modular, you can select the packages you want from it.

Google Play 服务现在是模块化的,您可以从中选择您想要的包。

To get analytics add:

要获取分析,请添加:

compile 'com.google.android.gms:play-services-analytics:7.3.0'

to you build.gradle's dependencies section

到您build.gradle的依赖项部分

P.S replace 7.3.0 with new version as they arrive, or replace with "+" to always get the latest

PS 将 7.3.0 替换为新版本,或替换为“+”以始终获取最新版本

回答by Bryan Dunlap

Android Studio is complaining that it can't find the Play Services library.

Android Studio 抱怨找不到 Play Services 库。

Follow the steps here to ensure Google Play Services SDK is installed (specifically, make sure 'Google Repository' is installed along with 'Google Play Services'): http://developer.android.com/google/play-services/setup.html#Install

按照此处的步骤确保安装了 Google Play 服务 SDK(特别是,确保安装了“Google 存储库”和“Google Play 服务”):http: //developer.android.com/google/play-services/setup。 html#安装

Then, make sure the following is added to the dependencies{}block in your build.gradle:

然后,确保将以下内容添加到dependencies{}build.gradle 中的块中:

compile 'com.google.android.gms:play-services:+'

Clean and rebuild.

清洁和重建。

回答by banoth ravinder

Add this line you build.gradle in Gradle Scripts folder

在 Gradle Scripts 文件夹中添加这行 build.gradle

dependencies {
        compile 'com.google.android.gms:play-services:11.2.0'
    }

with this i solved this issue.

有了这个我解决了这个问题。

回答by RredCat

Previous answers were correct.

以前的答案是正确的。

But in gradle:3.0 the compileconfiguration is now deprecated and should be replaced by implementationor api.

但在 gradle:3.0 中,该compile配置现已弃用,应替换为implementationor api

Check out more information in the documentation - API and implementation separation.

查看文档 - API 和实现分离中的更多信息。