gpt4 book ai didi

android - Google Play 服务客户端错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:46 25 4
gpt4 key购买 nike

我一直在努力让这个 android 项目在带有 gradle 的 android studio 中工作。我对这一切还很陌生,所以这可能是一个简单的问题,但我已经花了好几天时间,无法克服我在尝试运行我的项目时收到的这个错误:

Error:(25, 62) error: package com.google.android.gms.common.GooglePlayServicesClient does not exist
Error:(26, 62) error: package com.google.android.gms.common.GooglePlayServicesClient does not exist
Error:(27, 39) error: cannot find symbol class LocationClient
Error:(42, 60) error: cannot find symbol class ConnectionCallbacks
Error:(43, 3) error: cannot find symbol class OnConnectionFailedListener
Error:(82, 10) error: cannot find symbol class LocationClient
Error:(586, 26) error: cannot find symbol class LocationClient
Error:(618, 2) error: method does not override or implement a method from a supertype
Error:(627, 2) error: method does not override or implement a method from a supertype
Error:(635, 2) error: method does not override or implement a method from a supertype

Error:Execution failed for task ':compileDebugJava'.
> Compilation failed; see the compiler error output for details.

这是错误来源文件的顶部(我已标记有问题的行):

package edu.gatech.ppl.cycleatlanta;

import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.provider.Settings;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.***GooglePlayServicesClient***.ConnectionCallbacks;
import com.google.android.gms.common.***GooglePlayServicesClient***.OnConnectionFailedListener;
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;
import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.LatLng;

import java.text.SimpleDateFormat;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;

public class FragmentMainInput extends Fragment implements **ConnectionCallbacks**,
**OnConnectionFailedListener**, LocationListener,
OnMyLocationButtonClickListener {

public static final String ARG_SECTION_NUMBER = "section_number";

Intent fi;
TripData trip;
NoteData note;
boolean isRecording = false;
Timer timer;
float curDistance;

TextView txtDuration;
TextView txtDistance;
TextView txtCurSpeed;

int zoomFlag = 1;

Location currentLocation = new Location("");

final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

// Need handler for callbacks to the UI thread
final Handler mHandler = new Handler();
final Runnable mUpdateTimer = new Runnable() {
public void run() {
updateTimer();
}
};

private final static int MENU_USER_INFO = 0;
private final static int MENU_HELP = 1;

private final static int CONTEXT_RETRY = 0;
private final static int CONTEXT_DELETE = 1;

DbAdapter mDb;
GoogleMap map;
UiSettings mUiSettings;
private LocationClient mLocationClient;

private static final LocationRequest REQUEST = LocationRequest.create()
.setInterval(5000) // 5 seconds
.setFastestInterval(16) // 16ms = 60fps
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

public FragmentMainInput() {
}

当我将鼠标悬停在代码中标记的行时:

import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationClient;

它说:“无法解析符号”

这是我的 build.gradle 文件:

 buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'

// NOTE: Do not place your application dependencies here; they
// belong in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}


apply plugin: 'com.android.application'

dependencies {

compile 'com.android.support:appcompat-v7:22.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:7.0.0'
compile files('libs/android-support-v4.jar')

}

android {
compileSdkVersion 22
buildToolsVersion "22"
compileOptions.encoding = 'windows-1251'

defaultConfig {

minSdkVersion 19
targetSdkVersion 22
versionCode 2
versionName "2.0"
}


sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}

还有我的 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.gatech.ppl.cycleatlanta"
android:versionCode="2"
android:versionName="2.0" >

<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="22" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" >
</uses-feature>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
</uses-permission>
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="edu.gatech.ppl.cycleatlanta.TabsConfig"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.MainInputActivity"
android:label="@string/title_activity_main_input" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.TripPurposeActivity"
android:label="@string/title_activity_trip_purpose" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.UserInfoActivity"
android:label="@string/title_activity_user_info" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.TripMapActivity"
android:label="@string/title_activity_trip_map" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.SavedTripsActivity"
android:label="@string/title_activity_saved_trips" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.TripDetailActivity"
android:label="@string/title_activity_trip_detail" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.NoteTypeActivity"
android:label="@string/title_activity_note_type" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.NoteDetailActivity"
android:label="@string/title_activity_note_detail" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.NoteMapActivity"
android:label="@string/title_activity_note_map" >
</activity>
<activity
android:name="edu.gatech.ppl.cycleatlanta.SavedNotesActivity"
android:label="@string/title_activity_saved_notes" >
</activity>

<service
android:name="edu.gatech.ppl.cycleatlanta.RecordingService"
android:enabled="true"
android:exported="true" >
</service>

<activity
android:name="edu.gatech.ppl.cycleatlanta.MainActivity"
android:label="@string/title_activity_main" >
</activity>

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB9orX8RcKrVvF8Vg1_yMhIvu59XUW_inw" />

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>

</manifest>

在我看来,google play 服务链接存在问题。我遵循了几个不同的示例,并且肯定已经下载了它,但我无法让它工作。此外,我感觉我的 list (不确定 sdk 版本的正确目标)和 gradle 文件(jcenter 或 maven?并设置适当的依赖项)可能配置不正确。

这方面的任何帮助都会很棒我过去几天一直在搜索互联网,但我无法解决我确信这是一个简单的问题...

最佳答案

如果您使用的是 Google Play Services 7.0.0,您只需更改

import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;

import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;

如果您覆盖了 onDisconnected 方法,您还应该删除它。

关于android - Google Play 服务客户端错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29314457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com