Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

minifyEnabled true generating many warnings

Hi all after changing build.gradle properties minifyEnabled true I am getting following error. I read that If we use minifyEnabled true then

The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer

I want to use above benifits.

Warning:butterknife.internal.ButterKnifeProcessor: can't find superclass or     interface javax.annotation.processing.AbstractProcessor
Warning:retrofit.RxSupport$1: can't find superclass or interface rx.Observable$OnSubscribe
Warning:library class dagger.internal.codegen.GraphAnalysisErrorHandler extends or implements program class dagger.internal.Linker$ErrorHandler
Warning:library class dagger.internal.codegen.GraphAnalysisInjectBinding extends or implements program class dagger.internal.Binding
Warning:library class dagger.internal.codegen.GraphAnalysisLoader extends or implements program class dagger.internal.Loader
Warning:library class dagger.internal.codegen.GraphAnalysisProcessor$1 extends or implements program class dagger.internal.BindingsGroup
Warning:library class dagger.internal.codegen.GraphAnalysisProcessor$2 extends or implements program class dagger.internal.BindingsGroup
Warning:library class dagger.internal.codegen.GraphAnalysisProcessor$ProviderMethodBinding extends or implements program class dagger.internal.ProvidesBinding
Warning:library class dagger.internal.codegen.GraphAnalysisStaticInjection extends or implements program class dagger.internal.StaticInjection
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.AbstractProcessor
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced cla ss javax.annotation.processing.ProcessingEnvironment
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.Filer
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.tools.JavaFileObject
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Modifier
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.ElementKind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeVariable
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.util.Types
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeKind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.ArrayType
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.DeclaredType
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.ExecutableElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.ElementKind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.ExecutableElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.VariableElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.DeclaredType
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeKind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.SourceVersion
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced field 'javax.annotation.processing.ProcessingEnvironment processingEnv' in program class butterknife.internal.ButterKnifeProcessor
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.ProcessingEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.tools.Diagnostic$Kind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.Messager
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.util.Elements
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.PackageElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.AbstractProcessor
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.DeclaredType
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.ExecutableElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.VariableElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.ProcessingEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.Filer
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.tools.JavaFileObject
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Modifier
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.ElementKind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.util.Types
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeKind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.SourceVersion
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.tools.Diagnostic$Kind
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.Messager
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.util.Elements
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.PackageElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.tools.Diagnostic
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.util.Elements
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.util.Types
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.Filer
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.ProcessingEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.tools.JavaFileObject
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Modifier
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeVariable
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.ArrayType
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.DeclaredType
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeVariable
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.annotation.processing.RoundEnvironment
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeVariable
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.VariableElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.ExecutableElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.VariableElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.DeclaredType
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.type.TypeMirror
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.SourceVersion
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.Element
 Warning:butterknife.internal.ButterKnifeProcessor: can't find referenced class javax.lang.model.element.TypeElement
 Warning:com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
 Warning:com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getContentLengthLong()' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl
   Warning:com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl    


(http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
   Warning:there were 5 unresolved references to program class members.
     Your input classes appear to be inconsistent.
     You may need to recompile the code.
               (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
 :app:proguardRelease FAILED
  Error:Execution failed for task ':app:proguardRelease'.
 > java.io.IOException: Please correct the above warnings first.
 Information:BUILD FAILED
Information:Total time: 13.828 secs
 Information:1 error
Information:201 warnings
Information:See complete output in console

How to resolve this issue. Any suggestion will be appreciated. Thanks in advance.

like image 418
PPD Avatar asked Dec 20 '22 04:12

PPD


1 Answers

You will need to locate a file with proguard rules (proguard-rules.pro by default) and add following lines to it:

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

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

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

-keepattributes *Annotation*,EnclosingMethod,Signature
-keepnames class com.fasterxml.jackson.** { *; }
 -dontwarn com.fasterxml.jackson.databind.**
 -keep class org.codehaus.** { *; }
 -keepclassmembers public final enum org.codehaus.jackson.annotate.JsonAutoDetect$Visibility {
 public static final org.codehaus.jackson.annotate.JsonAutoDetect$Visibility *; }
-keep public class your.class.** {
  public void set*(***);
  public *** get*();
}

-dontwarn com.squareup.okhttp.**

your.class substitute with the one you serialize/deserialize.

This may not be sufficient to eliminate all your proguard-related errors but something to start with.

As @Deividi Cavarzan noted, if you use other libraries, I would suggest searching for their recommended proguard settings as well to avoid further problems. If no such configuration exists, but you still have errors coming from a library's classes you can try:

-keep class com.[library package].** {*;}.

Moreover, not all proguard side effects are caught at the build time, you can easily get your minified version crashing with runtime errors where a debug version works smoothly, thus testing is required afterwards.

like image 76
AndroidEx Avatar answered Jan 23 '23 06:01

AndroidEx