rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

IOException is thrown by following code. #121

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client 1.9.0-beta
Java environment Java 6, Android 2.3.4/Galaxy Ace S5830

Problem: An IOException is thrown by the following code:

    private void performAuthentication() {
        Log.d("GAWidget", "performAuthentication");
        GoogleCredential credential = new GoogleCredential();
        AccountManager accountManager = AccountManager.get(this);
        Account[] accounts = accountManager.getAccountsByType("com.google");
        Log.d("GAWidget", "after getting accountManager");
        Log.d("GAWidget", "after getting account"+"account.name: "+accounts[0].name);
        accountManager.getAuthToken(accounts[0], "oauth2:https://www.googleapis.com/auth/‌​analytics.readonly",
                true, new AccountManagerCallback<Bundle>() {

                    public void run(AccountManagerFuture<Bundle> future) {
                        try {
                            String token = future.getResult(15, TimeUnit.SECONDS).getString(AccountManager.KEY_AUTHTOKEN);
                            Log.d("GAWidget", "token: "+token);
                            useToken(token);
                        } catch (OperationCanceledException e) {
                            Log.e("GAWidget", "OperationCanceledException", e);
                        } catch (AuthenticatorException e) {
                            Log.e("GAWidget", "AuthenticatorException", e);
                        } catch (IOException e) {
                            Log.e("GAWidget", "IOException", e);
                        }
                    }

                }, null);
    }

Stack trace:

05-27 19:09:04.319: E/GAWidget(12487): IOException
05-27 19:09:04.319: E/GAWidget(12487): java.io.IOException
05-27 19:09:04.319: E/GAWidget(12487):  at 
android.accounts.AccountManager.convertErrorToException(AccountManager.java:1440
)
05-27 19:09:04.319: E/GAWidget(12487):  at 
android.accounts.AccountManager.access$400(AccountManager.java:138)
05-27 19:09:04.319: E/GAWidget(12487):  at 
android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:130
1)
05-27 19:09:04.319: E/GAWidget(12487):  at 
android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse
.java:69)
05-27 19:09:04.319: E/GAWidget(12487):  at 
android.os.Binder.execTransact(Binder.java:320)
05-27 19:09:04.319: E/GAWidget(12487):  at dalvik.system.NativeStart.run(Native 
Method)

Original issue reported on code.google.com by bal...@gmail.com on 29 May 2012 at 1:16

GoogleCodeExporter commented 9 years ago
Same report about this on Stack Exchange:

See 
http://stackoverflow.com/questions/10758255/ioexception-thrown-by-accountmanager
future-getresults-whereas-connection-is-aliv

I get the same error downloading the stock standard Tasks V1 Android Sample:

http://samples.google-api-java-client.googlecode.com/hg/tasks-android-sample/ins
tructions.html

Would love to know what it's about?

Original comment by eug...@snowball.co.za on 18 Jun 2012 at 8:36

GoogleCodeExporter commented 9 years ago
Having the same problem on 4.0.4 on a Nexus S.

Original comment by petersai...@gmail.com on 28 Jun 2012 at 2:33

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 14 Jan 2013 at 3:26