如何使用Google Drive REST API修复Proguard问题 [英] How to fix Proguard issue with Google Drive REST API

查看:308
本文介绍了如何使用Google Drive REST API修复Proguard问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Rest API v3将我的Android应用连接到Google云端硬盘。当我没有Proguard(minifyEnabled = false)时运行,一切都很好。但是,当启用proguard时,会调用错误的REST API方法。当我调用Drive.Files.get()。对驱动器根别名root执行时,我得到Drive.Files.list()。execute的结果。当我禁用minifyEnabled时,我看到了正确的结果。以下是控制正在运行的Proguard的build.gradle部分:

  buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile(' 'proguard-android.txt'),'proguard-rules.pro'
}
}

默认的Proguard文件是未经修改的文件,通过Android Studio 2.2进行发布(不是优化版本)。

这是我的proguard-rules的内容.pro文件

  -keepattributes EnclosingMethod 
-keepattributes InnerClasses
-dontoptimize

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

当我检入生成的mapping.txt时,我仍然可以看到cla这是imo shoudl已被保留的事实。例如:

com.google.api.client.auth.oauth.OAuthParameters - > com.google.api.client.auth.oauth.OAuthParameters:
java.security.SecureRandom RANDOM - > l
com.google.api.client.auth.oauth.OAuthSigner签名者 - >
java.lang.String回调 - > b
java。 lang.String consumerKey - > c
java.lang.String nonce - > d
java.lang.String realm - > e



有没有想过-keep class com.google。**会避免这种情况?



任何想法如何解决这个问题?



提前谢绝,

解决方案

您需要

  -keep class com.google。** {*;} 

  -keep class com.fasterxml。** {*;} 

您也可以尝试减少SDK的开销。这些规则非常宽泛。


I'm using the Google Rest API v3 to connect my android app to Google Drive. When I run without Proguard (minifyEnabled=false), all is well. However, when I enable proguard the wrong REST API methods are called. When I call Drive.Files.get().execute on the drive root alias "root" I get the result for a Drive.Files.list().execute. When I disable "minifyEnabled" I see the correct result. Here is the section of the build.gradle that controls running Proguard:

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

The default Proguard file is the unmodified one that gets distributes with Android Studio 2.2 (not the optimized version)

And this is the contents of my proguard-rules.pro file

-keepattributes EnclosingMethod
-keepattributes InnerClasses
-dontoptimize

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

When I check in the generated mapping.txt I still see renamed members in classes that imo shoudl have been "kept". For example:

com.google.api.client.auth.oauth.OAuthParameters -> com.google.api.client.auth.oauth.OAuthParameters: java.security.SecureRandom RANDOM -> l com.google.api.client.auth.oauth.OAuthSigner signer -> a java.lang.String callback -> b java.lang.String consumerKey -> c java.lang.String nonce -> d java.lang.String realm -> e

I would have thought "-keep class com.google.** " would have avoided this?

Any idea how to fix this?

THanks in advance,

解决方案

You need

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

and

-keep class com.fasterxml.** { *;}

Also you might try to keep less from the SDK. These rules are very wide.

这篇关于如何使用Google Drive REST API修复Proguard问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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