Already implemented below given solution but none of them are working still facing below listed warning.
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: retrofit2.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Add these lines into your proguard-rules.pro:
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
EDIT: try to add this:
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
into release buildType.
Adding below lines to the proguard will ignore these warnings solution from here
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-dontwarn javax.annotation.**
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Related
I added the following rules in my proguard.rules file.
Now when I am running a debug build from android-studio, it is working but when I generate a signed apk, it crashes on Launch.
#### -- Picasso --
-dontwarn com.squareup.okhttp.**
#### -- databinding --
-dontwarn android.databinding.**
#### -- Apache Commons --
-dontwarn org.apache.http.entity.**
And here are the logs
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForQaRelease'.
Job failed, see logs for details
Warning:org.apache.http.entity.mime.content.StringBody: can't find referenced class org.apache.http.util.Args
Warning:org.apache.http.entity.mime.content.StringBody: can't find referenced class org.apache.http.entity.ContentType
Warning:com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Warning:android.databinding.DataBindingUtil: can't find referenced class android.databinding.DataBindingComponent
You can add the rules below
# Okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
#databinding
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
# OkHttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
when I am setting minifiyEnabled to true in my any variant (debug or release) it gives me below error -
Warning:retrofit.appengine.UrlFetchClient: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
Warning:retrofit.appengine.UrlFetchClient: can't find referenced class com.google.appengine.api.urlfetch.HTTPHeader
Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate
Warning:library class android.webkit.WebViewClient depends on program class android.net.http.SslError
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.conn.scheme.HostNameResolver
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.params.HttpParams
Warning:library class org.apache.http.params.HttpConnectionParams depends on program class org.apache.http.params.HttpParams
Warning:there were 176 unresolved references to classes or interfaces.
Warning:there were 23 instances of library classes depending on program classes.
Warning:there were 6 unresolved references to program class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForProductionDebug'.
> Job failed, see logs for details
It is working fine in emulator or device if its lolipop or higher.
My problem resolved if i disable or make minifyEnabled to false, but I don't really want so.
My gradle tool is build:gradle:2.3.0'
And multiDexEnabled true
Note - I am not keeping any class or attribute in my proguard-rules.pro file.
After a lot of recherches and experiments I have got the solution. We have to add keep and dontwarn statments in our proguard-rules.pro file -
# Retrofit 1.X
-keep class com.squareup.okhttp.** { *; }
-keep class retrofit.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit.**
-dontwarn rx.**
-keepclasseswithmembers class * {
#retrofit.http.* <methods>;
}
# If in your rest service interface you use methods with Callback argument.
-keepattributes Exceptions
# If your rest service methods throw custom exceptions, because you've defined an ErrorHandler.
-keepattributes Signature
# Proguard configuration for amazon Jackson 2.x (fasterxml package instead of codehaus package)
-keep class com.amazonaws.** { *; }
-keepnames class com.amazonaws.** { *; }
-dontwarn com.amazonaws.**
-dontwarn com.fasterxml.**
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
-dontwarn org.mockito.**
-dontwarn sun.reflect.**
-dontwarn android.test.**
-dontwarn org.hamcrest.**
-dontwarn android.test.**
-dontwarn android.support.test.**
-keep class org.hamcrest.** {
*;
}
-keep class org.junit.** { *; }
-dontwarn org.junit.**
-keep class junit.** { *; }
-dontwarn junit.**
-keep class sun.misc.** { *; }
-dontwarn sun.misc.**
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
Note - I followed the warnings in messages and by picking one by one put my proguard rule accordingly.
if you are define proper proguard rules and still issue then please minifyEnabled true use only for application level for other module use minifyEnabled false.
Also if any lintError found and its not possible to solve then use below code
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
I have checked that and its works after so much effort.
Try to add the following lines to your proguard configuration:
# 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
It's for retrofit library. For other external libs you can use this method with own packages which you want to ignore;
-dontwarn org.apache.** - for example
More about ProGuard usage you can find here
I am trying to generate a signed APK with minifyEnabled set to true in Gradle:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
and added these to my proguard file:
-dontwarn okio.**
-dontwarn retrofit.**
but I get these errors:
Information:Gradle tasks [:app:assembleRelease]
Warning:retrofit2.Platform$Java8: can't find referenced method 'boolean isDefault()' in library class java.lang.reflect.Method
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:retrofit2.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:there were 8 unresolved references to classes or interfaces.
Warning:there were 1 unresolved references to library class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED
and can't build the apk file. We can't have minifyEnabled as true and use retrofit library? how can this be fixed?
You can have minifyEnabled as true and use any number of libraries. Just one thing to make note of its to add the proguard rules of every library in the proguard-rules.pro file. Check retrofits proguard handling here.
Lastly adding a proguard-rules.pro for your reference this is for the project im handling. (You might also need to notify proguard to exclude your POJO classes. Check example)
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/yogeshmalpani/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
-dontwarn com.squareup.okhttp.**
-keep class com.pushwoosh.** { *; }
-keep class com.arellomobile.** { *; }
-dontwarn com.pushwoosh.**
-dontwarn com.arellomobile.**
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { #butterknife.InjectView *;}
-keepattributes *Annotation*,EnclosingMethod,Signature,SourceFile,LineNumberTable
-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 *; }
# My POJO class directory
-keep public class com.app_name.model.pojo.** {
public void set*(***);
public *** get*();
public protected private *;
}
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
I think you are using retrofit 2,
-dontwarn okio.**
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
This question already have been asked many times but I am not able to resolve it. I am trying to export my app using eclipse for final release BUT I am getting the below error. I added all entries which others have suggested in other links but no help. Please help me how to get rid of this error.
Proguard returned with error code 1. See console
[2014-08-24 11:21:11 - ] Note: there were 1035 duplicate class definitions.
[2014-08-24 11:21:11 - ] Warning:com.google.api.client.extensions.jdo.JdoDataStoreFactory$JdoValue: can't find superclass or interface javax.jdo.spi.PersistenceCapable
[2014-08-24 11:21:11 - ] Warning: com.google.api.client.extensions.jdo.JdoDataStoreFactory$JdoDataStore: can't find referenced class javax.jdo.PersistenceManagerFactory
[2014-08-24 11:21:11 -
[2014-08-24 11:21:11 - ] Warning: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential: can't find referenced class com.google.android.gms.common.AccountPicker
[2014-08-24 11:21:11 - ] Warning: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential: can't find referenced class com.google.android.gms.auth.GoogleAuthUtil
You should check if you need to specify additional program jars.
Warning: there were 127 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Error: Please correct the above warnings first.
There was long error so I pasted relevant one. Below is my proguard-project.txt file entries.
-keep class android.support.v4.** { *; }
-dontwarn android.support.v4.**
-dontwarn javax.activation.**
-dontwarn javax.security.**
-dontwarn java.awt.**
-libraryjars <java.home>/lib/rt.jar
-keep class javax.** {*;}
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.harmony.** {*;}
-keep public class Mail {*;}
-dontshrink
-dontwarn org.mockito.**
-dontwarn sun.reflect.**
-dontwarn android.test.**
-keep class javax.ws.rs.** { *; }
-dontwarn com.fasterxml.jackson.**
-dontwarn org.xmlpull.v1.**
I resolved the issue. I added below two lines and now it is not giving any warning and I am able to generate .apk file successfully using eclipse.
-dontwarn javax.jdo.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**
Hope it will help someone. Thanks
I'm very short on time here, so I truly hope someone here has a clue how to fix these:
[proguard] Warning: android.support.v4.view.ViewConfigurationCompatFroyo: can't find referenced method 'int getScaledPagingTouchSlop()' in class android.view.ViewConfiguration
[proguard] Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentNavigableMap
[proguard] Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentSkipListMap
[proguard] Note: there were 2 unresolved dynamic references to classes or interfaces.
[proguard] You should check if you need to specify additional program jars.
[proguard] Warning: there were 1 unresolved references to program class members.
[proguard] Your input classes appear to be inconsistent.
[proguard] You may need to recompile them and try again.
[proguard] Alternatively, you may have to specify the options
[proguard] '-dontskipnonpubliclibraryclasses' and/or
[proguard] '-dontskipnonpubliclibraryclassmembers'.
I already tried adding multiple things:
-dontwarn **CompatHoneycomb
-dontwarn **CompatCreatorHoneycombMR2
-keep class android.support.v4.** { *; }
and also (for the jackson errors):
-libraryjars /Libraries/Joda/joda-time-1.6.2.jar
-libraryjars /Libraries/stax2-api-3.0.0.jar
-libraryjars /Libraries/jsr311-api-0.8.jar
-libraryjars /Libraries/httpmime-4.0.1.jar
Anyone have a clue what i'm missing in my proguard.cfg for these references? Or potentially some tips on how to investigate / resolve it more generally?
I brought it down from 472 warnings to just these, mostly by adding the dontwarn statements:
-dontwarn java.awt.,javax.security.,java.beans.,javax.xml.,java.util.,org.w3c.dom.
EDIT: Migrated to Answer
-dontwarn **CompatHoneycomb
-dontwarn **CompatCreatorHoneycombMR2
-dontwarn android.support.v4.view.**
-keep class android.support.v4.** { *; }
-dontwarn java.awt.**,javax.security.**,java.beans.**,javax.xml.**,java.util.**,org.w3c.dom.**
Edited my post above to display the answer.
Found it.
These seemed to help.
-dontwarn **CompatHoneycomb
-dontwarn **CompatCreatorHoneycombMR2
-dontwarn android.support.v4.view.**
-keep class android.support.v4.** { *; }
-dontwarn java.awt.**,javax.security.**,java.beans.**,javax.xml.**,java.util.**,org.w3c.dom.**
Add the following to your proguard configuration file.
-keep class org.codehaus.jackson.** {
*;
}
You do not need to obscure 3rd party libraries.