Proguard 和 Apache 的遗产

Proguard and apache legacy

我正在使用 Android API 23org.apache.http.legacy,所以我可以使用 Volley。一切正常,除非我使用 proguard。我收到此错误:

Error:Execution failed for task ':app:packageDevRelease'. Unable to compute hash of ...app/build/intermediates/classes-proguard/dev/release/classes.jar

我的 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.jakewharton.hugo'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "..."
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 3
        versionName "1.0.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    lintOptions {
        abortOnError false
        disable 'InvalidPackage'
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        ...
    }

    productFlavors {
        ...
    }
}

dependencies {
    compile files('libs/org.apache.http.legacy.jar')

    // #### Submodules
    compile project(':submodules:volley')

    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:percent:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'

    compile 'com.google.android.gms:play-services-location:8.4.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.maps.android:android-maps-utils:0.4'
    compile 'com.google.code.gson:gson:2.3'

    compile 'com.facebook.android:facebook-android-sdk:4.7.0'

    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'

    compile "com.daimajia.swipelayout:library:1.2.0@aar"
    compile 'com.kbeanie:image-chooser-library:1.5.2@aar'
    compile 'com.mcxiaoke.viewpagerindicator:library:2.4.1@aar'

    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
}

编辑:

将此行添加到 proguard 中提到 post:

-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-dontwarn com.android.volley.toolbox.**

我得到了同样的错误,但现在有一些友好的输出:

Unexpected failure during lint analysis of BaseClient.java (this is a bug in lint or one of the libraries it depends on) TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949) :app:validateExternalOverrideSigning :app:packageDevRelease FAILED

我的BaseClient.java有一些这样的方法:

 public static <T extends Object, U extends Object> void executePostRequest(
               String url, 
               T requestPayload,
               Class<U> responseClass,
               Response.Listener<U> successListener,
               Response.ErrorListener errorListener){}

private static <T> BaseRequest.AuthRetryListener<T> createAuthRequestListener()

等...

我怎样才能使这个工作?
谢谢。

编辑 2:
用户 ajcpsoares -ignorewarnings 解决方案有效。我也会留下这个link from ProGuard Troubleshooting docs. Also, since in my opinion this is a workaround instead of a solution I'll leave here the Android Open Source Project - Issue Tracker link

与其将 apache 遗留库作为 jar 包含,不如尝试如下添加:

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

如所述here

如果您在 proguard 文件中添加 -ignorewarnings,它会构建成功吗?