Files.List是空的,但仅当使用发行证书进行签名时才是 [英] Files.List is empty but only when signed with release certificate

查看:133
本文介绍了Files.List是空的,但仅当使用发行证书进行签名时才是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用适用于Android的Google Drive API遇到一个令人生气的错误。具体而言,在向用户呈现从Google Drive打开文件UI时,我使用以下代码查询文件夹中的文件:

  String query ='+ folderId +'in parents and trashed = false; 

Files.List request = service.files()。list()。setQ(query);

FileList files = request.execute();

java.util.List< File> items = files.getItems(); //返回null!

当我直接从Eclipse运行此代码(即使用调试证书签名)时,没有问题。但是,当我使用我们的发布证书构建并运行签名APK时,对files.getItems()的调用返回null。



奇怪的是,当getItems()返回null时,肯定有从Drive服务器返回的数据,因为调用files.toString()显示Json混乱,其中我已经确定了我的一些文件的文件名,所以我不认为这个问题是一个身份验证问题。

另外,在查询字符串中使用不同的folderId似乎对toString()返回的Json没有任何影响。基于logcat中积极的GC活动,它看起来像服务器可能会返回我的驱动器中的所有文件,特别是奇怪的考虑getItems()返回null。

请注意,代码在使用调试证书签名时工作得很好,因为我可以在我的应用内完美浏览我的Google Drive。

按照之前的评论:

在导出已签名的APK时,Proguard会有什么机会?如果您依赖变量名称将JSON映射到POJO上,则可能会在没有适当的Proguard排除/规则的情况下制动。查看 project.properties 文件并注释掉形式的任何行proguard.config =< file_name> 。之后,导出另一个已签名的APK并重新测试。


I am experiencing an infuriating bug with the Google Drive API for Android. Specifically, in presenting an "Open File from Google Drive" UI to the user, I am querying for the files in a folder using the following code:

String query = "'" + folderId + "' in parents and trashed = false";

Files.List request = service.files().list().setQ(query);

FileList files = request.execute();

java.util.List<File> items = files.getItems();  // Returns null!

When I run this code directly from Eclipse (i.e. signed with the debug certificate), there is no problem. However, when I build and run a signed APK using our release certificate, the call to files.getItems() returns null.

Oddly, while getItems() returns null, there is definitely data returned from the Drive server, because calling files.toString() shows a mess of Json, amongst which I have identified the filenames of a few of my files, so I don't think the problem is an authentication issue.

Also, using different folderIds in the query string does not seem to make any difference to the Json returned by toString(). Based on aggressive GC activity in logcat, it looks like the server might be returning ALL files in my drive, especially odd considering getItems() returns null.

Note that the code works absolutely fine when signed with the debug certificate, as I am able to browse my Google Drive perfectly from within my app.

解决方案

As per earlier comment:

Any chance Proguard kicks in when exporting your signed APK? If you rely on i.e. variable names to map the JSON onto POJOs, this is likely to brake without the appropriate Proguard exclusions/rules. Have a look in your project.properties file and comment out any lines in the form of proguard.config=<file_name>. After that, export another signed APK and retest.

这篇关于Files.List是空的,但仅当使用发行证书进行签名时才是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆