2016-03-04 77 views
2

我使用Android API 23org.apache.http.legacy,所以我可以使用Volley。除了當我使用proguard時,一切正常。我得到這個錯誤:Proguard和Apache傳統

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:[email protected]" 
    compile 'com.kbeanie:image-chooser-library:[email protected]' 
    compile 'com.mcxiaoke.viewpagerindicator:library:[email protected]' 

    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
} 

編輯:

添加了此行proguard在這個post提到:

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

我得到同樣的錯誤,但現在機智^ h一些友好的輸出:

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解決方案工作。我將離開ProGuard疑難解答文檔中的link。此外,因爲在我看來這是一個解決方法,而不是一個解決方案,我將離開這裏的Android開源項目 - 問題跟蹤器link也。

+0

我記得把這個添加到我的頂層gradle文件中,可能會有所幫助:'tasks.withType(JavaCompile){options.compilerArgs <<「-Xlint:deprecation」}' – m02ph3u5

+0

@ m02ph3u5感謝您的輸入。使用該行,我得到這樣的日誌:警告:(75,56)[deprecation] org.apache.http中的HttpStatus已被棄用,但在lint分析過程中仍然出現意外失敗...並且失敗。 – GuilhE

回答

2

如果您在您的proguard文件中添加-ignorewarnings,它會成功構建?

+0

好指出!它的工作原理,但我想這是更多的解決方法,而不是解決方法。我會接受這個答案,因爲它在一天結束時解決了我的問題。謝謝 – GuilhE

1

而是包括Apache遺留庫作爲一個罐子,嘗試如下添加它:

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

描述here

+0

感謝您的答案,但它不工作:( 使用.jar的好處是,HTTP類是由IntelliJ找到,如果我只是使用useLibrary我得到ClassNotFound IDEA錯誤。它編譯和它的工作,但它是有點無聊得到一些類與紅色下劃線。謝謝無論如何:) – GuilhE