我正在开发一款使用REST v3 api将数据同步到Google云端硬盘的Android应用。它工作正常然后突然停止工作。通常出现的要求访问Google云端硬盘的对话框不再显示。我已检查过SHA1指纹是否正确,并且已将google-services.json文件添加到我的项目中。我的项目发布到Google Play,如果有任何意义的话。
以下是连接代码:
// Gather credentials
credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), Arrays.asList(SCOPES)).setBackOff(new ExponentialBackOff());
SharedPreferences settings = getSharedPreferences("Roblu", Context.MODE_PRIVATE);
String accountName = settings.getString("accountName", "");
credential.setSelectedAccountName(accountName);
// Start Google services
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
service = new com.google.api.services.drive.Drive.Builder(transport, jsonFactory, credential).setApplicationName("Roblu").build();
如果我尝试同步数据,此行将返回null:
FileList files = service.files().list().setSpaces("appDataFolder").setFields("nextPageToken, files(id, name)").setPageSize(10).execute();