Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android proguard issues for release

I'm able to create builds for my android app, but when I turn on proguard i'm getting numerouos warnings, and then the build fails. The warnings are like the ones below:

Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpEntity
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.params.HttpParams
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.conn.ClientConnectionManager
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.methods.HttpUriRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpResponse
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.methods.HttpUriRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.protocol.HttpContext
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpResponse
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpHost
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpResponse
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpHost
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.protocol.HttpContext
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpResponse
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.methods.HttpUriRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.ResponseHandler
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.methods.HttpUriRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.ResponseHandler
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.protocol.HttpContext
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpHost
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.ResponseHandler
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpHost
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.HttpRequest
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.client.ResponseHandler
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.protocol.HttpContext
Warning: library class android.net.http.AndroidHttpClient depends on program class org.apache.http.entity.AbstractHttpEntity

It's complaining about libraries that were used in my project. My settings are below:

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        proguardFile file('proguard-rules.txt')
        signingConfig signingConfigs.release
    }
}

Within my proguard-rules.txt I have the following:

-libraryjars libs

All of my libraries are stored in the libs folder. Is there anything else i'm doing wrong?

like image 640
KVISH Avatar asked Aug 24 '14 07:08

KVISH


People also ask

How do I debug a ProGuard issue?

To debug Proguard/R8 configuration, navigate to app\build\outputs\mapping\release. There we can see the following files: configuration. txt – merged file with all configurations – from the app, default Android, AAPT, all the libraries, etc.

Is ProGuard deprecated?

For example, the useProGuard setting has been deprecated a while ago - maybe that's what you saw and you're misremembering it.

Is minifyEnabled true?

Code shrinking with R8 is enabled by default when you set the minifyEnabled property to true .

Does ProGuard remove unused resources?

It will help you not only to remove unused resources, but also to find potential bugs. The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names.


1 Answers

inspect the jars , creating a packages list in libs you are using.

Then try adding following for those packages in the list in your proguard config file:

-dontwarn org.codehaus.jackson.**

...

-keep        class org.codehaus.jackson.** { *; }
like image 122
Robert Rowntree Avatar answered Sep 23 '22 21:09

Robert Rowntree