Proguard代码1问题

时间:2013-12-02 19:57:22

标签: android proguard

我最近看到了proguard的使用,我在我的应用程序中使用谷歌分析服务。

在eclipse中我有 - proguard-project.txt 其中我添加了以下几行:

-keep class android.support.v4.** { *; }   
-dontwarn android.support.v4.**
-keep public class com.google.** {*;}

在项目属性中,我有未注释的行: -

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

我想在我的项目中实现proguard但是使用以下控制台输出触发了错误代码1:

[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache$1: can't find superclass or interface android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache$1: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache$1: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: com.google.tagmanager.LRUCache$1: can't find referenced class android.util.LruCache
[2013-12-03 00:49:21 - superman-v4-1] Warning: there were 9 unresolved references to classes or interfaces.
[2013-12-03 00:49:21 - superman-v4-1]          You may need to specify additional library jars (using '-libraryjars').
[2013-12-03 00:49:21 - superman-v4-1] java.io.IOException: Please correct the above warnings first.
[2013-12-03 00:49:21 - superman-v4-1]   at proguard.Initializer.execute(Initializer.java:321)
[2013-12-03 00:49:21 - superman-v4-1]   at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-12-03 00:49:21 - superman-v4-1]   at proguard.ProGuard.execute(ProGuard.java:86)
[2013-12-03 00:49:21 - superman-v4-1]   at proguard.ProGuard.main(ProGuard.java:492)

提前致谢。

2 个答案:

答案 0 :(得分:1)

您应该针对包含缺少的类android.util.LruCache的目标SDK构建;在这种情况下android-12或更高版本。只需将project.properties文件或build.gradle文件中的构建目标更改为该最新版本。

您仍然可以在minSdkVersion文件中指定其他targetSdkVersion和不同的AndroidManifest.xml

答案 1 :(得分:0)

也许请按照this SO question

中的说明尝试此配置
-keep class com.google.android.gms.analytics.**
-keep class com.google.analytics.tracking.**
-dontwarn com.google.android.gms.analytics.**
-dontwarn com.google.analytics.tracking.**