Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: GooglePlayServicesUtil﹕ Internal error occurred. Please see logs for detailed information. How do I fix this?

I have spent countless hours trying to figure out this google drive android api, and I have frustrated myself to the core trying to figure out how exactly to use it. I am using the getting started link on the google android developers website, and this is what I've done:

package viva.inspection.com.inspectionpicker;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveApi.ContentsResult;
import com.google.android.gms.drive.DriveId;
import com.google.android.gms.drive.MetadataChangeSet;
import com.google.android.gms.drive.OpenFileActivityBuilder;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveApi.ContentsResult;
import com.google.android.gms.drive.DriveId;
import com.google.android.gms.drive.MetadataChangeSet;
import com.google.android.gms.drive.OpenFileActivityBuilder;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;

import viva.inspection.com.inspectionpicker.MultiSpinner;


public class MyActivity extends Activity implements MultiSpinner.MultiSpinnerListener, AdapterView.OnItemSelectedListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
    GoogleApiClient mGoogleApiClient;
    final private static int RESOLVE_CONNECTION_REQUEST_CODE = 1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);
        Button save = (Button) findViewById(R.id.save);
        //array for the tasks multi-spinner
        String[] array = getResources().getStringArray(R.array.rooms_array);
        List<String> rooms = new ArrayList<String>(Arrays.asList(array));
        // Create an ArrayAdapter using the string array and a default spinner layout
        final Spinner roomSpinner = (Spinner) findViewById(R.id.rooms);
        Spinner itemsSpinner = (Spinner) findViewById(R.id.inspectionItems);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.rooms_array, android.R.layout.simple_spinner_item);
        // Specify the layout to use when the list of choices appears
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        // Apply the adapter to the spinner
        roomSpinner.setAdapter(
                new NothingSelectedSpinnerAdapter(
                        adapter,
                        R.layout.contact_spinner_row_nothing_selected,
                        // R.layout.contact_spinner_nothing_selected_dropdown, // Optional
                        this));
        roomSpinner.setOnItemSelectedListener(this);
        itemsSpinner.setOnItemSelectedListener(this);
        final MultiSpinner multiSpinner = (MultiSpinner) findViewById(R.id.multi_spinner);
        multiSpinner.setItems(rooms, "(Choose One)", this);
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
        save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MyActivity.this, ListActivity.class);
                intent.putExtra("NEW_VALUE", roomSpinner.getSelectedItem().toString());
                startActivity(intent);
            }
        });
    }

    ...

    @Override
    protected void onStart() {
        super.onStart();
        mGoogleApiClient.connect();
    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        if (connectionResult.hasResolution()) {
            try {
                connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
            } catch (IntentSender.SendIntentException e) {
                // Unable to resolve, message user appropriately
            }
        } else {
            GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
        }
    }

    ...

    @Override
    public void onConnected(Bundle bundle) {
        Drive.DriveApi.newContents(mGoogleApiClient)
                .setResultCallback(contentsCallback);
    }

    @Override
    public void onConnectionSuspended(int i) {

    }

    @Override
    protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        switch (requestCode) {
            case RESOLVE_CONNECTION_REQUEST_CODE:
                if (resultCode == RESULT_OK) {
                    mGoogleApiClient.connect();
                    DriveId driveId = (DriveId) data.getParcelableExtra(
                            OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
                }
                break;
        }
    }

    ResultCallback<ContentsResult> contentsCallback = new
            ResultCallback<ContentsResult>() {
                @Override
                public void onResult(ContentsResult result) {
                    if (!result.getStatus().isSuccess()) {
                        // Handle error
                        return;
                    }

                    MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
                            .setMimeType("text/html").build();
                    IntentSender intentSender = Drive.DriveApi
                            .newCreateFileActivityBuilder()
                            .setInitialMetadata(metadataChangeSet)
                            .setInitialContents(result.getContents())
                            .build(mGoogleApiClient);
                    try {
                        startIntentSenderForResult(intentSender, 1, null, 0, 0, 0);
                    } catch (IntentSender.SendIntentException e) {
                        // Handle the exception
                    }
                }
            };
}

This is my manifest, and I have no idea how the manifest should look like:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="viva.inspection.com.inspectionpicker">
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".ListActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MyActivity"
            android:label="MyActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.android.apps.drive.DRIVE_OPEN" />
                <data android:mimeType="application/vnd.google-apps.drive-sdk.1234567890" />
                <data android:mimeType="image/png" />
                <data android:mimeType="image/jpeg" />
                <data android:mimeType="image/jpg" />
            </intent-filter>
        </activity>
        <activity
            android:name=".InitialChoose"
            android:label="@string/title_activity_initial_choose"
            android:windowSoftInputMode="stateHidden">
        </activity>
    </application>

</manifest>

When I run the app, a dialog box appears that states "Unknown issue with Google Play services", and then in log cat this appears:

Error: GooglePlayServicesUtil﹕ Internal error occurred. Please see logs for detailed information. 

But there's nothing in the logs, so again I'm completely confused. I have looked at other questions, and I have indeed set up my app with the developer console, as per the instructions in the getting started link above.

I really need help.

Thanks in advance.

like image 308
Vishwa Iyer Avatar asked Jul 19 '14 03:07

Vishwa Iyer


3 Answers

I solved my problem; it seems that I didn't use the correct SHA1 fingerprint, so that's why it couldn't sign and authorize my application.

like image 57
Vishwa Iyer Avatar answered Oct 04 '22 12:10

Vishwa Iyer


Also make sure to fill out the "Consent Screen" information, if you see internal errors related to INVALID_CLIENT_ID.

See this related issue: G+ signin on android throws INVALID_CLIENT_ID

like image 32
Thomas R. Avatar answered Oct 04 '22 12:10

Thomas R.


In my case an application executed well, but one day it failed and a dialog box appeared with a message: "Unknown issue with Google Play services". After reinstalling the app the problem disappeared.

like image 35
CoolMind Avatar answered Oct 04 '22 12:10

CoolMind