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

时间:2022-10-12 00:26:12

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 tutorial to create application that uses Google Maps Android API v2. What I've done :

我正在按照教程创建使用Google Maps Android API v2的应用程序。我做了什么:

  1. download sample project from parse
  2. 从解析下载示例项目

  3. Import AnyWall-android\Anywall folder from downloaded project to Android Studio
  4. 将AnyWall-android \ Anywall文件夹从下载的项目导入Android Studio

  5. Rebuild project

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 maps highlighted red. The question is how to resolve these errors?

常见,位置和地图突出显示为红色。问题是如何解决这些错误?

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?)

我感谢任何帮助或方向(我应该检查什么?它是否缺少库?如果是,我应该添加什么库以及从哪里获取它?)

6 个解决方案

#1


25  

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 lib存在一些问题。您必须使用比最新版本(6. +)更旧的版本。尝试使用旧版本。我没有看到关于LocationClient.class的文档中有任何内容被弃用或遗漏...

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

#2


12  

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

P.S将新版本替换为7.3.0,或者替换为“+”以始终获得最新版本

#3


11  

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

我认为最好的解决方案是在Gradle上添加编译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(向下滚动)

#4


7  

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

Android Studio抱怨无法找到Play服务库。

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 Services SDK(具体而言,确保“Google Repository”与“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:

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

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

Clean and rebuild.

清洁和重建。

#5


4  

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.

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

#6


1  

Previous answers were correct.

以前的答案是正确的。

But in gradle:3.0 the compile configuration is now deprecated and should be replaced by implementation or api.

但是在gradle:3.0中,编译配置现已弃用,应该由implementation或api替换。

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

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

#1


25  

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 lib存在一些问题。您必须使用比最新版本(6. +)更旧的版本。尝试使用旧版本。我没有看到关于LocationClient.class的文档中有任何内容被弃用或遗漏...

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

#2


12  

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

P.S将新版本替换为7.3.0,或者替换为“+”以始终获得最新版本

#3


11  

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

我认为最好的解决方案是在Gradle上添加编译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(向下滚动)

#4


7  

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

Android Studio抱怨无法找到Play服务库。

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 Services SDK(具体而言,确保“Google Repository”与“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:

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

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

Clean and rebuild.

清洁和重建。

#5


4  

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.

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

#6


1  

Previous answers were correct.

以前的答案是正确的。

But in gradle:3.0 the compile configuration is now deprecated and should be replaced by implementation or api.

但是在gradle:3.0中,编译配置现已弃用,应该由implementation或api替换。

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

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