gpt4 book ai didi

android - 错误 : GooglePlayServicesUtil﹕ Internal error occurred. 请查看日志了解详细信息。我该如何解决?

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:52:27 28 4
gpt4 key购买 nike

我花了无数个小时试图弄清楚这个 google drive android api,并且我一直在努力弄清楚如何使用它。我在 google android 开发者网站上使用 getting started link,这就是我所做的:

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
}
}
};
}

这是我的 list ,我不知道 list 应该是什么样子:

<?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>

当我运行该应用程序时,会出现一个对话框,指出“Google Play 服务存在未知问题”,然后在 log cat 中会出现:

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

但是日志中什么也没有,所以我又完全糊涂了。我查看了其他问题,并且确实按照上面入门链接中的说明使用开发人员控制台设置了我的应用程序。

我真的需要帮助。

提前致谢。

最佳答案

我解决了我的问题;看来我没有使用正确的 SHA1 指纹,所以这就是它无法签署和授权我的应用程序的原因。

关于android - 错误 : GooglePlayServicesUtil﹕ Internal error occurred. 请查看日志了解详细信息。我该如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24836420/

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