我尝试处理想要从他们的谷歌分析帐户获取一些数据的用户的访问密钥。该代码完美运行了 1 天,但现在我无法再访问谷歌帐户了。
在我看来,Activity 无法再获得令牌。也许它应该更新,肯定不行。似乎是关于谷歌播放的东西!如果我看logcat。我上传了 Oncreate 方法和 logcat,希望有人可以通过查看 logcat 找到问题,在代码没有从 Token 请求中取回正确的变量后,我切断了 logcat。
请帮助我,有什么问题?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// enable logging
Logger.getLogger("analyticsproject").setLevel(LOGGING_LEVEL);
setContentView(R.layout.activity_main);
credential = GoogleAccountCredential.usingOAuth2(this, AnalyticsScopes.all());
SharedPreferences settings = getPreferences(Context.MODE_PRIVATE);
credential.setSelectedAccountName(settings.getString(PREF_ACCOUNT_NAME, null));
service = new com.google.api.services.analytics.Analytics.Builder(httpTransport, jsonFactory, credential)
.setApplicationName("Analytics Project").build();
startActivityForResult(credential.newChooseAccountIntent(),REQUEST_ACCOUNT_PICKER);
日志猫:
10-02 14:41:21.377 108-124/? W/audio_hw_primary﹕ out_write() limiting sleep time 46802 to 39909
10-02 14:41:21.441 8269-8269/? E/Trace﹕ error opening trace file: No such file or directory (2)
10-02 14:41:21.445 8269-8275/? E/jdwp﹕ Failed sending reply to debugger: Broken pipe
10-02 14:41:21.449 108-124/? W/audio_hw_primary﹕ out_write() limiting sleep time 49274 to 39909
10-02 14:41:21.541 8269-8269/? W/dalvikvm﹕ VFY: unable to resolve static field 4296 (common_google_play_services_install_title) in Lcom/google/android/gms/R$string;
10-02 14:41:21.585 5540-5540/com.google.android.gms.ui W/EGL_emulation﹕ eglSurfaceAttrib not implemented
10-02 14:41:21.657 8269-8269/? W/EGL_emulation﹕ eglSurfaceAttrib not implemented
10-02 14:41:23.289 310-311/? E/SocketStream﹕ readFully was waiting for 764896 bytes, got 49152
10-02 14:41:23.353 8269-8269/com.example.analyticsproject W/EGL_emulation﹕ eglSurfaceAttrib not implemented
10-02 14:41:23.357 8269-8284/com.example.analyticsproject W/dalvikvm﹕ VFY: unable to resolve static field 4288 (auth_client_play_services_err_notification_msg) in Lcom/google/android/gms/R$string;
10-02 14:41:23.861 5477-5496/com.google.android.gsf.login W/GLSActivity﹕ [sj] Status from wire: NeedPermission status: NEED_PERMISSION
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:284)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:858)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.example.analyticsproject.Analytics_requests.find_Accounts(Analytics_requests.java:34)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.example.analyticsproject.MainActivity$Login.doInBackground(MainActivity.java:623)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.example.analyticsproject.MainActivity$Login.doInBackground(MainActivity.java:602)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at java.lang.Thread.run(Thread.java:856)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ Caused by: com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:255)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:279)
10-02 14:41:23.865 8269-8284/com.example.analyticsproject W/System.err﹕ ... 14 more
10-02 14:41:24.337 5477-5499/com.google.android.gsf.login W/GLSActivity﹕ [sj] Status from wire: NeedPermission status: NEED_PERMISSION
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:284)
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:858)
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.example.analyticsproject.Analytics_requests.get_All_Accounts(Analytics_requests.java:66)
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.example.analyticsproject.MainActivity$Login.doInBackground(MainActivity.java:639)
10-02 14:41:24.337 8269-8284/com.example.analyticsproject W/System.err﹕ at com.example.analyticsproject.MainActivity$Login.doInBackground(MainActivity.java:602)