Proguard and error

江枫思渺然 提交于 2019-11-27 23:33:16

I had the same problem.

I found the answer here and it worked for me: How to add Apache HTTP API (legacy) as compile-time dependency to build.grade?

In your top level build.gradle file add:

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}
...

In your app-specific build.gradle file add:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    useLibrary 'org.apache.http.legacy'
    ...
}

Hope it works for you! it works now with ProGuard on. I had the exact same problem as you.

It looks like the warning comes from the google library, have you tried something like that:

-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.**

I would also try without the dontwarn cause I would assume you want to be warned if there is something to be warned about!

In Eclipse find org.apache.http.legacy.jar in ..sdk/platforms/android-23/optional.

Import it like external jar, check order/export and in proguard type:

-keep class org.apache.http.** { *; }
-keepclassmembers class org.apache.http.** {*;}
-dontwarn org.apache.**

-keep class android.net.http.** { *; }
-keepclassmembers class android.net.http.** {*;}
-dontwarn android.net.**

Add following lines in your proguard file.

-keep class org.apache.http.** { *; }
-keep class org.apache.** { *; }
-dontwarn org.apache.**
-dontwarn org.apache.http.**
-dontwarn org.apache.commons.**
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!