简体   繁体   English

Proguard 设置错误

[英]Proguard setup error

I am facing this problems while enabling proguard in my release build.我在发布版本中启用 proguard 时遇到了这个问题。

Information:Gradle tasks [:app:assembleRelease] Warning:com.google.maps.android.kml.KmlRenderer$1: can't find referenced field 'int window' in program class com.google.maps.android.R$id信息:Gradle 任务 [:app:assembleRelease] 警告:com.google.maps.android.kml.KmlRenderer$1:在程序类 com.google.maps.android.R$id 中找不到引用的字段“int window”

Warning:there were 1 unresolved references to program class members.警告:有 1 个未解析的对程序类成员的引用。

Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.警告:处理任务时出现异常 java.io.IOException:请先更正上述警告。 Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.错误:任务 ':app:transformClassesAndResourcesWithProguardForRelease' 的执行失败。 Job failed, see logs for details Information:BUILD FAILED Information:Total time: 26.457 secs Information:1 error Information:3 warnings Information:See complete output in console作业失败,详细信息请参见日志信息:BUILD FAILED 信息:总时间:26.457 秒信息:1 个错误信息:3 个警告信息:查看控制台中的完整输出

My Proguard setup rule looks like this.我的 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.**

Looks like an inner class in the class KmlRenderer tries to access a non-existing field in the generated class com.google.maps.android.R$id.看起来像 KmlRenderer 类中的内部类试图访问生成的类 com.google.maps.android.R$id 中不存在的字段。 Maybe the error is resolved by using an updated version of the google maps library.也许通过使用谷歌地图库的更新版本解决了错误。

You can also disable the warning with您还可以禁用警告

-dontwarn com.google.maps.android.kml.KmlRenderer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM