我的应用程序具有以下gradle配置
我也在https://console.developers.google.com/apis/credentials
上注册了我的应用将以下代码用于驱动器api
private void connectToDrive(){
GoogleApiClient.ConnectionCallbacks ccb = new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
Log.i("app" , "connected");
}
@Override
public void onConnectionSuspended(int i) {
}
};
GoogleApiClient.OnConnectionFailedListener cfl = new GoogleApiClient.OnConnectionFailedListener(){
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.i("app", "GoogleApiClient connection failed: " + connectionResult.toString());
if (!connectionResult.hasResolution()) {
GoogleApiAvailability.getInstance().getErrorDialog(MainActivity.this, connectionResult.getErrorCode(), 0).show();
return;
}
try {
connectionResult.startResolutionForResult(MainActivity.this, 4);
} catch (IntentSender.SendIntentException e) {
Log.e("app", "Exception while starting resolution activity", e);
}
}
};
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(ccb)
.addOnConnectionFailedListener(cfl)
.build();
mGoogleApiClient.connect();
}
此模块gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.ali.datastore"
minSdkVersion 15
targetSdkVersion 23
versionCode 3
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile files('libs/jxl.jar')
compile 'com.google.android.gms:play-services-drive:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
这是项目gradle文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
每次我这样做都会产生以下错误 如果问题仍然存在,请与Google Play服务联系。 This is Error Message 我正在使用HTC M8手机
在googling的最后3天,我没有得到任何解决方案。我在这里缺少什么?