【问题标题】:org.apache.http.legacy.jar Proguard errororg.apache.http.legacy.jar Proguard 错误
【发布时间】:2016-08-13 09:44:28
【问题描述】:

当我使用httpclient-4.5.2.jar + httpcore-4.4.4.jar 时,Proguard 工作正常。但是当我用org.apache.http.legacy.jar替换上面的包时,报下面Proguard错误:

Proguard returned with error code 1. See console
Note: there were 273 duplicate class definitions.
Warning: library class android.webkit.WebView depends on program class android.net.http.SslCertificate
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
      You should check if you need to specify additional program jars.
Warning: there were 3 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
java.io.IOException: Please correct the above warnings first.
    at proguard.Initializer.execute(Initializer.java:321)
    at proguard.ProGuard.initialize(ProGuard.java:211)
    at proguard.ProGuard.execute(ProGuard.java:86)
    at proguard.ProGuard.main(ProGuard.java:492)

我该如何解决这个问题?

【问题讨论】:

    标签: android android-proguard


    【解决方案1】:

    在你的build.gradle 中使用下面的代码,而不是导入 jar 文件:

    useLibrary 'org.apache.http.legacy'
    

    作为参考,请检查此代码:

    android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"
    useLibrary 'org.apache.http.legacy'
    
    defaultConfig {
        applicationId "com.application.abc"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-22
      • 2018-04-25
      • 2014-11-19
      相关资源
      最近更新 更多