<android app =“”>在使用Google Play服务时出现问题

时间:2017-05-20 13:06:35

标签: android google-play-services google-api-client drive

我的应用程序具有以下gradle配置

  1. Min Sdk版本:15
  2. 目标Sdk版本:23
  3. 编译'com.google.android.gms:play-services-drive:9.6.1'
  4. classpath'com.google.gms:google-services:3.0.0'
  5. Android版本6.0
  6. Google Play服务版本10.2.98
  7. 我也在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天,我没有得到任何解决方案。我在这里缺少什么?

0 个答案:

没有答案