1

Google playservices で自分自身を認証するためにバックグラウンドでトークンを取得しようとしていますが、それができません。

トークンを取得するための私のコードは次のとおりです。

private class GetTokenTask extends AsyncTask<String, Void, String> {

        @Override
        protected String doInBackground(String... params) {
            try {
                return fetchToken(params[0]);
            } catch (IOException e) {
                return null;
            }
        }

        @Override
        protected void onPostExecute(String result) {
            if (result != null) {
                ProximityApi.getInstance(MainActivity.this)
                        .setAuthToken(result);
                setResult(RESULT_OK);
                finish();
            }
        }
    }

私が得るエラー応答は次のとおりです。

10-06 03:05:08.855    1876-1893/com.infotech.palmtree.proxybeacon W/art﹕ Suspending all threads took: 21.270ms
10-06 03:05:11.402    1876-1893/com.infotech.palmtree.proxybeacon W/art﹕ Suspending all threads took: 65.002ms
10-06 03:05:11.463    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ com.google.android.gms.auth.UserRecoverableAuthException: DeviceManagementSyncDisabled
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.zza(Unknown Source)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity.fetchToken(MainActivity.java:106)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity.access$100(MainActivity.java:24)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity$GetTokenTask.doInBackground(MainActivity.java:87)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at com.infotech.palmtree.proxybeacon.MainActivity$GetTokenTask.doInBackground(MainActivity.java:82)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:292)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-06 03:05:11.634    1876-2140/com.infotech.palmtree.proxybeacon W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
10-06 03:05:11.635    1876-2140/com.infotech.palmtree.proxybeacon I/Timeline﹕ Timeline: Activity_launch_request id:com.google.android.gms time:6855445
10-06 03:05:11.722    1876-1876/com.infotech.palmtree.proxybeacon I/Timeline﹕ Timeline: Activity_launch_request id:com.google.android.gms time:6855532
4

1 に答える 1

0

エラーは一目瞭然です。これ:UserRecoverableAuthException: DeviceManagementSyncDisabled根本的な原因のようです。(当該エラーの 説明)

テスト デバイスで同期を有効にする必要があり、それによってエラーが解決されるはずです。

PS: ログの次のテキストは、Auth が失敗したためです。

于 2015-10-06T22:44:48.067 に答える