Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android Studio上的Google API错误_Java_Android_Google Maps_Google Play Services_Google Maps Android Api 2 - Fatal编程技术网

Java Android Studio上的Google API错误

Java Android Studio上的Google API错误,java,android,google-maps,google-play-services,google-maps-android-api-2,Java,Android,Google Maps,Google Play Services,Google Maps Android Api 2,我发现Google Play服务库存在一些问题 我已导入这些文件: import com.google.android.gms.location.LocationServices; import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.android.gms.common.api.GoogleApiClient; 在整个“GoogleAppClient”项目中,我都遇到了错误:- 这里我得到

我发现Google Play服务库存在一些问题

我已导入这些文件:

import com.google.android.gms.location.LocationServices;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
在整个“GoogleAppClient”项目中,我都遇到了错误:-

这里我得到了locationClient/LocationServices/GoogleAppClient的错误

locationClient = new GoogleApiClient.Builder(this)
              .addApi(LocationServices.API)
下面是“locationClient”的获取错误

这里我得到了“onConnectionSuspended”的错误


确保在build.gradle依赖项中包含Google Play服务,例如:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.3.0'
}

记住:有错误吗?添加完整日志确保您拥有清单和sha1代码中的所有权限。@MohamedSalad是的,也需要这些权限,但不设置这些权限不会导致编译错误,会导致运行时错误。
 @Override
  public void onStop() {
    // If the client is connected
    if (locationClient.isConnected()) {
      stopPeriodicUpdates();
    }

    // After disconnect() is called, the client is considered "dead".
    locationClient.disconnect();

    super.onStop();
  }

  /*
   * Called when the Activity is restarted, even before it becomes visible.
   */
  @Override
  public void onStart() {
    super.onStart();

    // Connect to the location services client
    locationClient.connect();
  }
  @Override
  public void onConnectionSuspended(int i) {
       Log.i(Application.APPTAG, "GoogleApiClient connection has been suspend");
  }
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.3.0'
}