Proguard设置错误

时间:2018-02-07 06:59:09

标签: java android apk android-proguard

我在发布版本中启用proguard时遇到了这个问题。

  

信息:Gradle任务[:app:assembleRelease]   警告:com.google.maps.android.kml.KmlRenderer $ 1:在程序类com.google.maps.android.R $ id

中找不到引用字段'int window'      

警告:程序类成员有1个未解析的引用。

     

警告:处理任务java.io.IOException时出现异常:请先纠正上述警告。   错误:任务':app:transformClassesAndResourcesWithProguardForRelease'的执行失败。    作业失败,请参阅日志了解详情   信息:建筑失败   信息:总时间:26.457秒   信息:1错误   信息:3个警告   信息:请参阅控制台中的完整输出

     

我的Proguard设置规则如下所示。

-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
 @butterknife.* <fields>;
 }

-keepclasseswithmembernames class * {
 @butterknife.* <methods>;
 }
-dontwarn io.card.**

##############################################
#Okio Rules
##############################################
-dontwarn okio.**
-keep class okio.** { *; }

##############################################
#Picasso
##############################################
-dontwarn com.squareup.picasso.**
-dontwarn com.squareup.okhttp.**
-dontwarn javax.annotation.**

##############################################
#otto
##############################################
-keepattributes *Annotation*
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}



###############################################
#Retrofit rules
###############################################
# Platform calls Class.forName on types which do not exist on Android             to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at     runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters     and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions


###################################################
#Active android
###################################################
-keep class com.activeandroid.** { *; }
-keep class com.activeandroid.**.** { *; }
-keep class * extends com.activeandroid.Model
-keep class * extends com.activeandroid.serializer.TypeSerializer
-keep class com.example.model.** { *; }



-keepclasseswithmembers class com.jombay.vger.rx.resources.** {
  <init>(...);
  public void set*(***);
  public *** get*();
}

-keepclasseswithmembers public class          com.jombay.vger.retrofit.resources.** {
  public protected private <init>(...);
  public void set(*);
  public ** get*();
}

-keepclasseswithmembers public class com.jombay.vger.utils.** {
  public protected private <init>(...);
}

-keepclassmembers class * {
 @org.codehaus.jackson.annotate.* *;
}

-keep class com.fasterxml.jackson.databind.ObjectMapper {*;}
-keep class com.fasterxml.jackson.databind.ObjectWriter {*;}

-keepattributes InnerClasses

 -dontskipnonpubliclibraryclassmembers
 -keepclassmembers class * {
  @com.fasterxml.jackson.annotation.JsonCreator *;
  @com.fasterxml.jackson.annotation.JsonProperty *;
 }
 -dontskipnonpubliclibraryclassmembers

################################################
#Logs
################################################
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
public static *** wtf(...);
}


###################################################
#Google
###################################################
-keep class com.google.analytics.** { *; }
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**

1 个答案:

答案 0 :(得分:0)

看起来类KmlRenderer中的内部类尝试访问生成的类com.google.maps.android.R $ id中的不存在的字段。也许通过使用谷歌地图库的更新版本来解决错误。

您也可以使用

禁用警告
-dontwarn com.google.maps.android.kml.KmlRenderer