我想獲得Android上的谷歌+登錄工作。 我的問題是,當我使用eclipse運行它時,google dev網站上提供的示例完美地工作。當我簽署apk並在我的設備上手動安裝apk時,我收到了一些奇怪的錯誤。Android的谷歌+登錄
活動:
package com.watchmon.watchmon;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
import com.google.android.gms.plus.PlusClient;
public class Testlogin extends Activity implements ConnectionCallbacks, OnConnectionFailedListener{
private static final String TAG = "ExampleActivity";
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
private ProgressDialog mConnectionProgressDialog;
private PlusClient mPlusClient;
private ConnectionResult mConnectionResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testlogin);
mPlusClient = new PlusClient.Builder(this,this,this)
.build();
// Anzuzeigende Statusmeldung, wenn der Verbindungsfehler nicht behoben ist
mConnectionProgressDialog = new ProgressDialog(this);
mConnectionProgressDialog.setMessage("Signing in...");
}
@Override
protected void onStart() {
super.onStart();
mPlusClient.connect();
}
@Override
protected void onStop() {
super.onStop();
mPlusClient.disconnect();
}
@Override
public void onConnectionFailed(ConnectionResult result) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
} catch (SendIntentException e) {
mPlusClient.connect();
}
}
// Speichern Sie das Ergebnis und beheben Sie den Verbindungsfehler bei einem Klick des Nutzers.
mConnectionResult = result;
}
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
}
@Override
public void onDisconnected() {
Log.d(TAG, "disconnected");
}
@Override
public void onConnected(Bundle connectionHint) {
// TODO Auto-generated method stub
String accountName = mPlusClient.getAccountName();
Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show();
}
}
錯誤:
05-21 14:32:47.430: W/ActivityManager(368): in case of changing top-activity!![com.google.android.gms]
05-21 14:32:47.430: I/ActivityManager(368): START {cmp=com.google.android.gms/.plus.activity.AccountSignUpActivity (has extras) u=0} from pid -1
05-21 14:32:47.500: I/ActivityManager(368): Start proc com.google.android.gms.ui for activity com.google.android.gms/.plus.activity.AccountSignUpActivity: pid=30247 uid=10015 gids={3003, 1015, 1028, 1007, 3002, 3001, 1006, 2001, 3006}
05-21 14:32:47.520: D/ActivityThread(30247): setTargetHeapUtilization:0.25
05-21 14:32:47.520: D/ActivityThread(30247): setTargetHeapIdealFree:8388608
05-21 14:32:47.520: D/ActivityThread(30247): setTargetHeapConcurrentStart:2097152
05-21 14:32:47.530: V/ActivityThread(30247): Class path: /system/framework/com.android.location.provider.jar:/data/app/com.google.android.gms-1.apk, JNI path: /data/data/com.google.android.gms/lib
05-21 14:32:47.590: I/MultiDex(30247): load(/data/app/com.google.android.gms-1.apk, forceReload=false)
05-21 14:32:47.640: I/MultiDex(30247): Need extracted file /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip
05-21 14:32:47.640: I/MultiDex(30247): No extraction needed for /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip of size 1809539
05-21 14:32:47.660: D/GCM(27444): GcmService start Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE
05-21 14:32:47.660: I/dalvikvm(30247): Could not find method android.accounts.AccountManager.getAccountsByTypeForPackage, referenced from method buu.c
05-21 14:32:47.660: W/dalvikvm(30247): VFY: unable to resolve virtual method 1178: Landroid/accounts/AccountManager;.getAccountsByTypeForPackage (Ljava/lang/String;Ljava/lang/String;)[Landroid/accounts/Account;
05-21 14:32:47.660: D/dalvikvm(30247): VFY: replacing opcode 0x6e at 0x000c
05-21 14:32:47.660: E/dalvikvm(30247): Could not find class 'android.os.UserManager', referenced from method buu.c
05-21 14:32:47.660: W/dalvikvm(30247): VFY: unable to resolve check-cast 540 (Landroid/os/UserManager;) in Lbuu;
05-21 14:32:47.660: D/dalvikvm(30247): VFY: replacing opcode 0x1f at 0x000c
05-21 14:32:47.660: E/dalvikvm(30247): Could not find class 'android.os.UserManager', referenced from method buu.d
05-21 14:32:47.660: W/dalvikvm(30247): VFY: unable to resolve check-cast 540 (Landroid/os/UserManager;) in Lbuu;
05-21 14:32:47.660: D/dalvikvm(30247): VFY: replacing opcode 0x1f at 0x000f
05-21 14:32:47.660: E/dalvikvm(30247): Could not find class 'android.os.UserManager', referenced from method buu.e
05-21 14:32:47.660: W/dalvikvm(30247): VFY: unable to resolve check-cast 540 (Landroid/os/UserManager;) in Lbuu;
05-21 14:32:47.660: D/dalvikvm(30247): VFY: replacing opcode 0x1f at 0x000d
05-21 14:32:47.660: E/dalvikvm(30247): Could not find class 'android.app.AppOpsManager', referenced from method buw.a
05-21 14:32:47.660: W/dalvikvm(30247): VFY: unable to resolve check-cast 301 (Landroid/app/AppOpsManager;) in Lbuw;
05-21 14:32:47.660: D/dalvikvm(30247): VFY: replacing opcode 0x1f at 0x000e
05-21 14:32:47.700: W/ActivityManager(368): in case of changing top-activity!![com.google.android.gms]
05-21 14:32:47.700: I/ActivityManager(368): START {act=com.google.android.gms.common.account.CHOOSE_ACCOUNT pkg=com.google.android.gms cmp=com.google.android.gms/.common.account.AccountPickerActivity (has extras) u=0} from pid 30247
05-21 14:32:47.810: D/dalvikvm(368): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-21 14:32:47.930: D/dalvikvm(368): GC_EXPLICIT freed 3042K, 46% free 33301K/61063K, paused 4ms+11ms, total 119ms
05-21 14:32:47.990: D/SurfaceFlinger(154): createSurface for (1 x 1), name=com.google.android.gms/com.google.android.gms.plus.activity.AccountSignUpActivity
05-21 14:32:48.010: D/libEGL(30247): loaded /system/lib/egl/libEGL_tegra.so
05-21 14:32:48.010: E/(30247): file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt: not found!
05-21 14:32:48.010: I/(30247): Attempting to load EGL implementation /system/lib//egl/libEGL_tegra_impl
05-21 14:32:48.020: I/(30247): Loaded EGL implementation /system/lib//egl/libEGL_tegra_impl
05-21 14:32:48.020: D/libEGL(30247): loaded /system/lib/egl/libGLESv1_CM_tegra.so
05-21 14:32:48.020: D/libEGL(30247): loaded /system/lib/egl/libGLESv2_tegra.so
05-21 14:32:48.030: I/(30247): Loading GLESv2 implementation /system/lib//egl/libGLESv2_tegra_impl
05-21 14:32:48.030: D/OpenGLRenderer(30247): Enabling debug mode 0
05-21 14:32:48.040: D/SurfaceFlinger(154): createSurface for (720 x 1280), name=com.google.android.gms/com.google.android.gms.plus.activity.AccountSignUpActivity
05-21 14:32:48.080: I/ActivityManager(368): Displayed com.google.android.gms/.plus.activity.AccountSignUpActivity: +589ms
公共和調試簽名密鑰已被添加到谷歌的控制檯項目。 吐司說內部錯誤。 如果任何人有任何想法,在此先感謝:)
https://androidbeasts.wordpress.com/2015/08/22/android-login-using-google/#more-157 – Aakash