I try to handle access keys to users, who wants to get some data from their google analytics account. The code worked perfectly for 1 day, but now i cant access the google account any more.
It seems to me like the Activity cant get the token anymore. Perhaps it should be renewed, something definitely not working.Seems to be something about google play! if i looking at the logcat. I uploaded the Oncreate method & the logcat, hope someone can find the problem just by looking at the logcat, i cut the logcat after the code doesnt get the right variables back from the Token request.
Please help me, what is wrong ?
@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);
Log cat:
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)