如何配置ProGuard的使用谷歌驱动器SDK的Andr​​oid应用程序? [英] How to configure proguard for Android application using Google Drive SDK?

查看:184
本文介绍了如何配置ProGuard的使用谷歌驱动器SDK的Andr​​oid应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse中包括ProGuard的建设快速入门时:运行驱动器应用程序在Android 的例子应用程序,该应用程序就失去了上传文件的能力。

When Eclipse includes proguard when building the Quickstart: Run a Drive App on Android example application, the application loses its ability to upload files.

在谷歌的API客户端ID似乎是正确配置时给予不ProGuard的构建的应用程序的发布版本工作正常。然而,当使用ProGuard启用内置在Eclipse相同的发布版本的应用程序的文件上传不起作用。这是我的问题的ProGuard配置文件:

The Google API client id appears to be correctly configured given the release version of the application works fine when built without proguard. However that same release version application's file upload doesn't work when built in Eclipse with proguard enabled. Here is my problematic proguard configuration file:

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

-libraryjars /libs/android-support-v4.jar
-libraryjars /libs/google-api-client-1.13.2-beta.jar
-libraryjars /libs/google-api-client-android-1.13.2-beta.jar
-libraryjars /libs/google-api-services-drive-v2-rev70-1.13.2-beta.jar
-libraryjars /libs/google-http-client-1.13.1-beta.jar
-libraryjars /libs/google-http-client-android-1.13.1-beta.jar
-libraryjars /libs/google-http-client-gson-1.13.1-beta.jar
-libraryjars /libs/google-http-client-jackson-1.13.1-beta.jar
-libraryjars /libs/google-http-client-jackson2-1.13.1-beta.jar
-libraryjars /libs/google-http-client-protobuf-1.13.1-beta.jar
-libraryjars /libs/google-oauth-client-1.13.1-beta.jar
-libraryjars /libs/gson-2.1.jar
-libraryjars /libs/guava-jdk5-13.0.jar
-libraryjars /libs/jackson-core-2.0.5.jar
-libraryjars /libs/jackson-core-asl-1.9.9.jar
-libraryjars /libs/jsr305-1.3.9.jar
-libraryjars /libs/protobuf-java-2.4.1.jar

# Add any project specific keep options here:

-keep class com.google.**
-dontwarn com.google.**

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

这是logcat中显示产生的错误:

And here are the resulting errors displayed in logcat:

D/ALSAModule(  162): setHardwareParams: reqBuffSize 1024 channels 2 sampleRate 48000
D/ALSAModule(  162): setHardwareParams: buffer_size 2048, period_size 1024, period_cnt 2
W/System.err(10707): com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
W/System.err(10707): {
W/System.err(10707):   "code": 403,
W/System.err(10707):   "errors": [
W/System.err(10707):     {
W/System.err(10707):       "domain": "usageLimits",
W/System.err(10707):       "message": "Access Not Configured",
W/System.err(10707):       "reason": "accessNotConfigured"
W/System.err(10707):     }
W/System.err(10707):   ],
W/System.err(10707):   "message": "Access Not Configured"
W/System.err(10707): }
W/System.err(10707):    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.b(Unknown Source)
W/System.err(10707):    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.a(Unknown Source)
W/System.err(10707):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.b(Unknown Source)
W/System.err(10707):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.d(Unknown Source)
W/System.err(10707):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.e(Unknown Source)
W/System.err(10707):    at com.example.testupload2.a.run(Unknown Source)
W/System.err(10707):    at java.lang.Thread.run(Thread.java:856)
D/overlay (  159): Unset pipe=VG0 dpy=0; Unset pipe=RGB1 dpy=0;
D/alsa_ucm(  162): snd_use_case_set(): uc_mgr 0x40e59388 identifier _verb value Inactive
D/alsa_ucm(  162): Set mixer controls for HiFi Lowlatency enable 0
D/alsa_ucm(  162): snd_use_case_set(): uc_mgr 0x40e59388 identifier _disdev value Camcorder Tx

我是个新手ProGuard的。关于什么是正确的ProGuard配置应该是任何提示?

I'm a proguard novice. Any tips on what the correct proguard configuration should be?

更新:
我提出这个问题到了Android的问题跟踪器(问题54765 )。

UPDATE:
I submitted this problem to the Android issue tracker (issue 54765).

更新2: 现在,谷歌推动Android API是在谷歌播放服务来实现,我的应用规模不断减少,ProGuard的的设置是的彻底的记录。这两个好东西。

UPDATE 2: Now that the Google Drive Android API is implemented within Google Play Services, my application size has decreased and the setup of proguard is thoroughly documented. Both good things.

推荐答案

使用在 ProGuard的 - 谷歌 - API-client.txt 来preserve以下的必需的属性和类成员。

Use the following in your proguard-google-api-client.txt to preserve the required attributes and class members.

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-keepclassmembers class * {
  @com.google.api.client.util.Key <fields>;
}

-keep class com.google.** { *;}
-keep interface com.google.** { *;}
-dontwarn com.google.**

# Needed by google-http-client-android when linking against an older platform version
-dontwarn com.google.api.client.extensions.android.**

# Needed by google-api-client-android when linking against an older platform version
-dontwarn com.google.api.client.googleapis.extensions.android.**

这篇关于如何配置ProGuard的使用谷歌驱动器SDK的Andr​​oid应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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