Android proguard issues for release

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

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?

回答1:

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.** { *; } 


回答2:

Your libraries contain duplicates of the android.http classes, which are already present in the Android runtime. This may cause conflicts. You should remove the duplicate libraries from your project.

See the ProGuard manual > Troubleshooting > Warning: library class ... depends on program class ...



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!