0

My app has following gradle configurations

  1. Min Sdk version:15
  2. Target Sdk version:23
  3. compile 'com.google.android.gms:play-services-drive:9.6.1'
  4. classpath 'com.google.gms:google-services:3.0.0'
  5. Android version 6.0
  6. Google Play Services version 10.2.98

Also i registered my app on https://console.developers.google.com/apis/credentials

Using the following code for drive 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();
}

This module gradle file

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'

and this is project gradle file

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()
    }
}

every time i do this it gives following error is having trouble with google play service if problem persists contact the developer. This is Error Message I am using HTC M8 mobile with

For last 3 days of googling i did not get any solution to my problem. What am i missing here?

  • please post your gradle file... – Opiatefuchs May 20 '17 at 13:08
  • i added both files in my question as well – Ali Subhan Kazmi May 20 '17 at 13:31
  • is there an error thrown or is it a dialog with an error message that appears? – Opiatefuchs May 20 '17 at 13:55
  • I think you should use the latest version of drive: `'com.google.android.gms:play-services-drive:10.2.6'` – Opiatefuchs May 20 '17 at 14:11
  • when i try to app 'com.google.android.gms:play-services-drive:10.2.6' it gives error – Ali Subhan Kazmi May 20 '17 at 14:25
  • Error:(26, 13) Failed to resolve: com.google.android.gms:play-services-drive:10.2.6 – Ali Subhan Kazmi May 20 '17 at 14:25
  • i also added error message image to question – Ali Subhan Kazmi May 20 '17 at 14:25
  • ok for the error with 10.2.6: be sure you have the latest version in Android Studio. Go to the sdk manager and update all play services. Next after you have done this, uninstall your app, uninstall google play services from your device. Then download the latest google play services from app store. After that, install your app again. – Opiatefuchs May 20 '17 at 15:00
  • i installed com.google.android.gms:play-services-drive:10.2.6. Now it changed the error message. Now it says "app is having trouble with Google play service PLEASE TRY AGAIN". PLEASE try again is added in error message. This might help you identifying the problem. – Ali Subhan Kazmi May 20 '17 at 15:31
  • can you please check the error stack in your android monitor. There must be thrown anything or an error message that indicates which problem it is.... – Opiatefuchs May 20 '17 at 15:37
  • have you done what I said about uninstall your app and google play services from your device? – Opiatefuchs May 20 '17 at 15:38
  • Yes i did uninstall my app. I uninstalled and reinstalled google play services today 3 hours ago so i dont think i need to do that again. And error message onConnectionFailedListener shows Internal Error and message is null. – Ali Subhan Kazmi May 20 '17 at 15:51
  • ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null, message=null} – Ali Subhan Kazmi May 20 '17 at 15:57
  • I also uninstalled and reinstalled play services as well my app but still same problem. – Ali Subhan Kazmi May 20 '17 at 16:19
  • thats it, the error stack gave more information. See here:http://stackoverflow.com/questions/21280794/error-connectionresultstatuscode-internal-error-resolution-null – Opiatefuchs May 20 '17 at 19:00

0 Answers0