use room ORM testing with minify and proguard - android

I am using room ORM in my project every things good but when i test project with minify minifyEnabled true i face to this error i tried many but did not work. and the following warnings:
Information:Gradle tasks [:app:assembleDebug, :app:assembleDebugAndroidTest]
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find superclass or interface org.easymock.IArgumentMatcher
Warning:org.hamcrest.integration.JMock1Adapter: can't find superclass or interface org.jmock.core.Constraint
Warning:library class android.test.AndroidTestCase extends or implements program class junit.framework.TestCase
Warning:library class android.test.AndroidTestRunner extends or implements program class junit.runner.BaseTestRunner
Warning:library class android.test.InstrumentationTestCase extends or implements program class junit.framework.TestCase
Warning:library class android.test.InstrumentationTestSuite extends or implements program class junit.framework.TestSuite
Warning:library class android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests extends or implements program class junit.framework.TestCase
Warning:android.support.test.espresso.core.deps.guava.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning:android.support.test.espresso.core.deps.guava.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning:android.support.test.espresso.core.deps.guava.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning:android.support.test.espresso.core.deps.guava.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning:android.support.test.espresso.core.deps.guava.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1: can't find referenced class sun.misc.Unsafe
Warning:android.support.test.runner.MonitoringInstrumentation: can't find referenced method 'android.app.Instrumentation$ActivityResult execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Activity,android.content.Intent,int)' in program class android.support.test.internal.runner.hidden.ExposedInstrumentationApi
Warning:android.support.test.runner.MonitoringInstrumentation: can't find referenced method 'android.app.Instrumentation$ActivityResult execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Activity,android.content.Intent,int,android.os.Bundle)' in program class android.support.test.internal.runner.hidden.ExposedInstrumentationApi
Warning:android.support.test.runner.MonitoringInstrumentation: can't find referenced method 'android.app.Instrumentation$ActivityResult execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Fragment,android.content.Intent,int,android.os.Bundle)' in program class android.support.test.internal.runner.hidden.ExposedInstrumentationApi
Warning:com.squareup.javawriter.JavaWriter: can't find referenced class javax.lang.model.element.Modifier
Warning:org.hamcrest.JMock1Matchers: can't find referenced class org.jmock.core.Constraint
Warning:org.hamcrest.beans.HasPropertyWithValue: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.HasPropertyWithValue$2: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.Introspector
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.BeanInfo
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.IntrospectionException
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.Introspector
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.BeanInfo
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.IntrospectionException
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.SamePropertyValuesAs: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.SamePropertyValuesAs$PropertyMatcher: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.EasyMock
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.IArgumentMatcher
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.EasyMock
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.IArgumentMatcher
Warning:org.hamcrest.integration.JMock1Adapter: can't find referenced class org.jmock.core.Constraint
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean
Warning:there were 118 unresolved references to classes or interfaces.
Warning:there were 5 instances of library classes depending on program classes.
Warning:there were 3 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:transformClassesAndResourcesWithProguardForDebugAndroidTest'.
> Job failed, see logs for details
Information:BUILD FAILED
Information:Total time: 8.388 secs
Information:1 error
Information:48 warnings
Information:See complete output in console
I think I need to add some procured rules for this android.arch.persistence.room:testing:1.0.0-alpha9 but I don't know what.
thank you for your help.

Related

Warning: org.apache.poi.hssf.usermodel.DummyGraphics2d

When i try use from proguard these errors and warnings are comming and APK file not builds:
Warnings:
org.apache.poi.hssf.usermodel.DummyGraphics2d: can't find superclass
or interface java.awt.Graphics2D
org.apache.poi.hssf.usermodel.EscherGraphics: can't find superclass or
interface java.awt.Graphics
org.apache.poi.hssf.usermodel.EscherGraphics2d: can't find superclass
or interface java.awt.Graphics2D
org.apache.poi.sl.draw.DrawSimpleShape$1: can't find superclass or
interface javax.xml.stream.EventFilter
org.apache.poi.sl.draw.Drawable$DrawableHint: can't find superclass or
interface java.awt.RenderingHints$Key
org.apache.poi.sl.draw.PathGradientPaint: can't find superclass or
interface java.awt.Paint
org.apache.poi.sl.draw.PathGradientPaint$PathGradientContext: can't
find superclass or interface java.awt.PaintContext
org.apache.poi.sl.draw.SLGraphics: can't find superclass or interface
java.awt.Graphics2D org.apache.poi.sl.draw.geom.PresetGeometries$1:
can't find superclass or interface javax.xml.stream.EventFilter
com.fasterxml.jackson.databind.ext.DOMSerializer: can't find
referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.Transient
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.ConstructorProperties
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.Transient
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.ConstructorProperties
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.Transient
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.ConstructorProperties
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.Transient
com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find
referenced class java.beans.ConstructorProperties
io.jsonwebtoken.impl.Base64Codec: can't find referenced class
javax.xml.bind.DatatypeConverter
io.jsonwebtoken.impl.crypto.EllipticCurveProvider: can't find
referenced class org.bouncycastle.jce.ECNamedCurveTable
org.apache.poi.ddf.EscherMetafileBlip: can't find referenced class
java.awt.Rectangle org.apache.poi.ddf.EscherMetafileBlip: can't find
referenced class java.awt.Dimension
org.apache.poi.ddf.EscherMetafileBlip: can't find referenced class
java.awt.Rectangle org.apache.poi.ddf.EscherMetafileBlip: can't find
referenced class java.awt.Dimension
org.apache.poi.ddf.EscherPictBlip: can't find referenced class
java.awt.Rectangle org.apache.poi.ddf.EscherPictBlip: can't find
referenced class java.awt.Dimension
Errors:
java.lang.RuntimeException: Job failed, see logs for details at
com.android.build.gradle.internal.transforms.ProGuardTransform.transform(ProGuardTransform.java:207)
at
com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at
com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at
org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.io.IOException: Please correct the above warnings first. at
proguard.Initializer.execute(Initializer.java:485) at
proguard.ProGuard.initialize(ProGuard.java:271) at
proguard.ProGuard.execute(ProGuard.java:113) at
com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:64)
at
com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:262)
at
com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:65)
at
com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:176)
at com.android.builder.tasks.Job.runTask(Job.java:47) at
com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:282) ... 1
more
proguad-rules.pro file
# apache
-keep public class org.apache.poi.** {*;}
What is the problem?
-dontwarn org.apache.poi.**
This solved the issue for me.

Getting com.loopj.android.http.AsyncHttpClient after enabling Proguard

I have read this, It looks like its a known issue from quite some time. But i was not receiving any warning or crash when i was not using pro-guard. After enabling it, I am receiving around 500 warnings like following;
Warning:com.loopj.android.http.AsyncHttpClient: can't find referenced
class cz.msebera.android.httpclient
I have tried following, but still all of the warnings are there.
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
useLibrary 'org.apache.http.legacy'
}
I am not using http-client library, but there may be some other library that I am using in my project is using this.
Warnings
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.HttpResponse
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.Header
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.StatusLine
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.HttpResponse
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.HttpEntity
Warning:com.loopj.android.http.RangeFileAsyncHttpResponseHandler: can't find referenced class cz.msebera.android.httpclient.client.methods.HttpUriRequest
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.protocol.HTTP
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.client.utils.URLEncodedUtils
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.client.utils.URLEncodedUtils
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.HttpEntity
Warning:com.loopj.android.http.RequestParams: can't find referenced class cz.msebera.android.httpclient.message.BasicNameValuePair
Warning:rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.ConcurrentCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.ConcurrentSequencedCircularArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.MpscLinkedQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscArrayQueue: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.SpscArrayQueueProducerFields: can't find referenced class sun.misc.Unsafe
Warning:rx.internal.util.unsafe.UnsafeAccess: can't find referenced class sun.misc.Unsafe
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 757 unresolved references to classes or interfaces.
Warning:there were 18 instances of library classes depending on program classes.
Warning:there were 8 unresolved references to program class members.
Warning:there were 2 unresolved references to library class members.
After adding the lines provided in Hitesh Gehlot answer. I am receiving these 5 warnings.
Information:Gradle tasks [:app:assembleRelease]
Warning:com.algolia.search.saas.APIClient: can't find referenced method 'org.json.JSONObject put(java.lang.String,java.util.Collection)' in library class org.json.JSONObject
Warning:com.algolia.search.saas.Index: can't find referenced method 'org.json.JSONObject put(java.lang.String,java.util.Collection)' in library class org.json.JSONObject
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:there were 3 instances of library classes depending on program classes.
Warning:there were 2 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.
paste these lines in proguard-rules.pro file
-dontwarn com.loopj.android.http.**
-dontwarn org.apache.http.**
-dontwarn rx.internal.util.**

Proguard causes 100 "can't find referenced class" warnings, ignores keep rules for springframework and jackson

My code compiles and runs fine in debug mode, but once I use a build configuration with minifyEnabled true I get these warnings which prevent compilation:
Warning:there were 100 unresolved references to classes or interfaces.
Warning:there were 2 unresolved references to program class members.
For readabilities sake I'll include the full output at the bottom.
There are two libraries that are causing these warnings, springframework and jackson. Those libraries are included in my project via gradle like so:
compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
compile 'com.fasterxml.jackson.core:jackson-core:2.8.5'
compile 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
apt "org.androidannotations:rest-spring:$AAVersion"
compile "org.androidannotations:rest-spring-api:$AAVersion"
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
If I use -dontwarn for both of these libraries, like many people suggest for these types of issues, the app compiles but crashes with an obfuscated crashlog during startup - I tried retracing it with the mapping file, but that's not working either - I'm reasonably certain that the app crashes due to the autogenerated (through android annotations) class RestClient_ when initializing a jackson mapping class, the exception is the following:
java.lang.NoSuchFieldError: No static field PUBLIC_ONLY of type
Lcom/myapp/app/mv$a; in class Lcom/myapp/app/mv$a; or its superclasses
(declaration of 'com.myapp.app.mv$a' appears in
/data/app/com.myapp.app-1/base.apk)
Although on a different phone, the exception has no message. It's pretty obvious that this is a result of proguard.
My full proguard file can be found here https://gist.github.com/Syzygy2048/02a44032611d40720bad36b5e3b37db6
Here are a couple of things I already tried (I tried more, but I only started writing things down after a while). The attempts focus on fixing springframework first. (Had to put this in a gist because stackoverflow wouldn't let me post otherwise)
https://gist.github.com/Syzygy2048/f1bdabc9f2ea091aa8faec67c62dd8bb
full error log:
Information:Gradle tasks [:myappApp:assembleMyappPublicRelease]
Warning:org.springframework.core.convert.support.ConvertingPropertyEditorAdapter: can't find superclass or interface java.beans.PropertyEditorSupport
Warning:com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.Transient
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.ConstructorProperties
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.nio.file.Path
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.Transient
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.ConstructorProperties
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.Transient
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.ConstructorProperties
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.Transient
Warning:com.fasterxml.jackson.databind.ext.Java7SupportImpl: can't find referenced class java.beans.ConstructorProperties
Warning:com.fasterxml.jackson.databind.ext.NioPathDeserializer: can't find referenced class java.nio.file.Path
Warning:com.fasterxml.jackson.databind.ext.NioPathDeserializer: can't find referenced class java.nio.file.Paths
Warning:com.fasterxml.jackson.databind.ext.NioPathDeserializer: can't find referenced class java.nio.file.Path
Warning:com.fasterxml.jackson.databind.ext.NioPathSerializer: can't find referenced class java.nio.file.Path
Warning:org.springframework.core.convert.support.ConvertingPropertyEditorAdapter: can't find referenced class java.beans.PropertyEditorSupport
Warning:org.springframework.core.convert.support.ConvertingPropertyEditorAdapter: can't find referenced method 'void setValue(java.lang.Object)' in program class org.springframework.core.convert.support.ConvertingPropertyEditorAdapter
Warning:org.springframework.core.convert.support.ConvertingPropertyEditorAdapter: can't find referenced method 'java.lang.Object getValue()' in program class org.springframework.core.convert.support.ConvertingPropertyEditorAdapter
Warning:org.springframework.core.convert.support.ConvertingPropertyEditorAdapter: can't find referenced class java.beans.PropertyEditorSupport
Warning:org.springframework.http.client.HttpComponentsClientHttpRequest: can't find referenced class org.apache.http.entity.ByteArrayEntityHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequest: can't find referenced class org.apache.http.impl.client.CloseableHttpClient
Warning:org.springframework.http.client.HttpComponentsClientHttpRequest: can't find referenced class org.apache.http.client.methods.CloseableHttpResponse
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.impl.client.HttpClients
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.impl.client.CloseableHttpClient
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.protocol.HttpClientContext
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.Configurable
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.config.RequestConfig
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.config.RequestConfig$Builder
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.config.RequestConfig
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpGetHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpDeleteHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpHeadHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpOptionsHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpPostHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpPutHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpTraceHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.methods.HttpPatch
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.impl.client.CloseableHttpClient
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.config.RequestConfig
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.impl.client.HttpClients
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.protocol.HttpClientContext
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.config.RequestConfig
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.config.RequestConfig$Builder
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.impl.client.CloseableHttpClient
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.client.config.RequestConfig
Warning:org.springframework.http.client.HttpComponentsClientHttpRequestFactory: can't find referenced class org.apache.http.impl.client.CloseableHttpClient
Warning:org.springframework.http.client.HttpComponentsClientHttpResponse: can't find referenced class org.apache.http.client.methods.CloseableHttpResponse
Warning:org.springframework.http.client.HttpComponentsClientHttpResponse: can't find referenced class org.apache.http.util.EntityUtilsHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpResponse: can't find referenced class org.apache.http.client.methods.CloseableHttpResponse
Warning:org.springframework.http.client.HttpComponentsClientHttpResponse: can't find referenced class org.apache.http.util.EntityUtilsHC4
Warning:org.springframework.http.client.HttpComponentsClientHttpResponse: can't find referenced class org.apache.http.client.methods.CloseableHttpResponse
Warning:org.springframework.http.client.HttpComponentsStreamingClientHttpRequest: can't find referenced class org.apache.http.impl.client.CloseableHttpClient
Warning:org.springframework.http.client.HttpComponentsStreamingClientHttpRequest: can't find referenced class org.apache.http.client.methods.CloseableHttpResponse
Warning:org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter: can't find referenced class org.simpleframework.xml.core.Persister
Warning:org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter: can't find referenced class org.simpleframework.xml.Root
Warning:org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter: can't find referenced class org.simpleframework.xml.Serializer
Warning:there were 100 unresolved references to classes or interfaces.
Warning:there were 2 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 ':myappApp:transformClassesAndResourcesWithProguardForMyappPublicRelease'.
Job failed, see logs for details
Information:BUILD FAILED
Information:Total time: 23.68 secs
Information:1 error
Information:59 warnings
Information:See complete output in console
It turns out that adding this to my proguard file fixed my issues.
-keepclassmembers class com.myapp.models.** {
*; }
-keep class com.fasterxml.jackson.annotation.** { *; }
-dontwarn com.fasterxml.jackson.databind.**
-dontwarn org.springframework.**
So in the end I could ignore most of those warnings after all. As I said simply ignoring them lead to crashes, which are fixed by not obfuscating jackson annotations and by not obfuscating my model classes which seem to be needed so that the json <--> pojo conversion can happen.

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForArmRelease'

Build is not generating
I am using Espresso for automated testing but build is not generating.
and I found that this error are generated when this below mentioned dependency is included.
compile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
Not sure, is it the only reason for error.
here is the stack trace
Information:Gradle tasks [:app:assembleArmRelease]
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find superclass or interface org.easymock.IArgumentMatcher
Warning:org.hamcrest.integration.JMock1Adapter: can't find superclass or interface org.jmock.core.Constraint
Warning:library class android.test.AndroidTestCase extends or implements program class junit.framework.TestCase
Warning:library class android.test.AndroidTestRunner extends or implements program class junit.runner.BaseTestRunner
Warning:library class android.test.InstrumentationTestCase extends or implements program class junit.framework.TestCase
Warning:library class android.test.InstrumentationTestSuite extends or implements program class junit.framework.TestSuite
Warning:library class android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests extends or implements program class junit.framework.TestCase
Warning:com.squareup.javawriter.JavaWriter: can't find referenced class javax.lang.model.element.Modifier
Warning:org.hamcrest.JMock1Matchers: can't find referenced class org.jmock.core.Constraint
Warning:org.hamcrest.beans.HasPropertyWithValue: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.HasPropertyWithValue$2: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.Introspector
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.BeanInfo
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.IntrospectionException
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.Introspector
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.BeanInfo
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.IntrospectionException
Warning:org.hamcrest.beans.PropertyUtil: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.SamePropertyValuesAs: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.beans.SamePropertyValuesAs$PropertyMatcher: can't find referenced class java.beans.PropertyDescriptor
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.EasyMock
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.IArgumentMatcher
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.EasyMock
Warning:org.hamcrest.integration.EasyMock2Adapter: can't find referenced class org.easymock.IArgumentMatcher
Warning:org.hamcrest.integration.JMock1Adapter: can't find referenced class org.jmock.core.Constraint
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.ManagementFactory
Warning:org.junit.rules.DisableOnDebug: can't find referenced class java.lang.management.RuntimeMXBean
Warning:there were 91 unresolved references to classes or interfaces.
Warning:there were 5 instances of library classes depending on program classes.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForArmRelease'.
> java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED

Android Volley Signed Apk Issue

I am working with an application where I am using volley plus with android studio. I am using volley plus gradle version 'dev.dworks.libs:volleyplus:+' gradle. When I make signed apk of my app my build process terminated with some warning and errors with runProguard true. There is any solution to solve this.
Warning:com.android.volley.toolbox.HttpClientStack$HttpPatch: can't find superclass or interface org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.android.volley.toolbox.multipart.MultipartEntity: can't find superclass or interface org.apache.http.entity.AbstractHttpEntity
Warning:com.android.volley.cache.SimpleImageLoader: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.android.volley.cache.plus.SimpleImageLoader: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.android.volley.misc.MultipartUtils: can't find referenced class org.apache.http.util.EncodingUtils
Warning:com.android.volley.misc.Utils: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.misc.Utils: can't find referenced class org.apache.http.Header
Warning:com.android.volley.misc.Utils: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.misc.Utils: can't find referenced class org.apache.http.Header
Warning:com.android.volley.misc.Utils: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.misc.Utils: can't find referenced class org.apache.http.Header
Warning:com.android.volley.misc.Utils: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.StatusLine
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpEntity
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.Header
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.StatusLine
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpEntity
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.StatusLine
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpEntity
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.Header
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.StatusLine
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.StatusLine
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.HttpEntity
Warning:com.android.volley.toolbox.BasicNetwork: can't find referenced class org.apache.http.Header
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.message.BasicNameValuePair
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.HttpClient
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpPost
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.entity.ByteArrayEntity
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpPost
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpGet
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpDelete
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpPut
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpHead
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpOptions
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpTrace
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.HttpClient
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.HttpClient
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.NameValuePair
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpPost
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.HttpEntity
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpPost
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpPut
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.HttpEntity
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.android.volley.toolbox.HttpClientStack: can't find referenced class org.apache.http.client.methods.HttpUriRequest
Warning:com.android.volley.toolbox.HttpClientStack$HttpPatch: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.android.volley.toolbox.HttpClientStack$HttpPatch: can't find referenced method 'void setURI(java.net.URI)' in program class com.android.volley.toolbox.HttpClientStack$HttpPatch
Warning:com.android.volley.toolbox.HttpClientStack$HttpPatch: can't find referenced class org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning:com.android.volley.toolbox.HttpHeaderParser: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning:com.android.volley.toolbox.HttpHeaderParser: can't find referenced class org.apache.http.impl.cookie.DateParseException
Warning:com.android.volley.toolbox.HttpHeaderParser: can't find referenced class org.apache.http.impl.cookie.DateUtils
Warning:com.android.volley.toolbox.HttpHeaderParser: can't find referenced class org.apache.http.impl.cookie.DateParseException
Warning:com.android.volley.toolbox.HttpStack: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.ProtocolVersion
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.message.BasicStatusLine
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.message.BasicHeader
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.ProtocolVersion
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.StatusLine
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.Header
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.ProtocolVersion
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.StatusLine
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.message.BasicHttpResponse
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.HttpResponse
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.HttpEntity
Warning:com.android.volley.toolbox.HurlStack: can't find referenced class org.apache.http.entity.BasicHttpEntity
Warning:com.android.volley.toolbox.Volley: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.android.volley.toolbox.VolleyTickle: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.android.volley.toolbox.multipart.BasePart: can't find referenced class org.apache.http.util.ByteArrayBuffer
Warning:com.android.volley.toolbox.multipart.BasePart: can't find referenced class org.apache.http.util.EncodingUtils
Warning:com.android.volley.toolbox.multipart.BasePart: can't find referenced class org.apache.http.util.ByteArrayBuffer
Warning:com.android.volley.toolbox.multipart.BasePart: can't find referenced class org.apache.http.util.EncodingUtils
Warning:com.android.volley.toolbox.multipart.BasePart: can't find referenced class org.apache.http.util.ByteArrayBuffer
Warning:com.android.volley.toolbox.multipart.Boundary: can't find referenced class org.apache.http.util.EncodingUtils
Warning:com.android.volley.toolbox.multipart.MultipartEntity: can't find referenced class org.apache.http.entity.AbstractHttpEntity
Warning:com.android.volley.toolbox.multipart.MultipartEntity: can't find referenced method 'void setContentType(java.lang.String)' in program class com.android.volley.toolbox.multipart.MultipartEntity
Warning:com.android.volley.toolbox.multipart.MultipartEntity: can't find referenced class org.apache.http.entity.AbstractHttpEntity
Warning:com.android.volley.ui.PhotoView: can't find referenced method 'float sqrt(float)' in library class android.util.FloatMath
Warning:com.rey.material.drawable.ContactChipDrawable: can't find referenced method 'float ceil(float)' in library class android.util.FloatMath
Warning:com.rey.material.text.style.ContactChipSpan: can't find referenced method 'float ceil(float)' in library class android.util.FloatMath
Warning:there were 158 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:there were 2 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)
Warning:there were 3 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
:app:proguardRelease FAILED
Error:Execution failed for task ':app:proguardRelease'.
> java.io.IOException: Please correct the above warnings first.
Use this code in ProGuard:
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-dontwarn com.android.volley.toolbox.**
Since android API 23 Apache HTTP Client is removed from Android:
https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client
But Volley still uses it, that's why there is warn about can't find referenced class
We can ignore these warns, because Volley is still compiled using API 22:
https://github.com/mcxiaoke/android-volley/blob/master/gradle.properties
Still should think about other better libray like OkHttp, which uses HttpURLConnection, if Volley doesn't update in the future.

Categories

Resources