2016-03-08 70 views
1

我無法生成帶有模糊處理的已簽名APK。我收到以下錯誤:Apache Legacy的Proguard問題(不使用庫時)

Information:Gradle tasks [:app:assembleRelease]            
:app:preBuild UP-TO-DATE                  
:app:preReleaseBuild UP-TO-DATE                
:app:checkReleaseManifest                 
:app:preDebugBuild UP-TO-DATE                
:app:prepareComAndroidSupportAnimatedVectorDrawable2320Library UP-TO-DATE     
:app:prepareComAndroidSupportAppcompatV72320Library UP-TO-DATE        
:app:prepareComAndroidSupportDesign2320Library UP-TO-DATE         
:app:prepareComAndroidSupportRecyclerviewV72320Library UP-TO-DATE       
:app:prepareComAndroidSupportSupportV42320Library UP-TO-DATE         
:app:prepareComAndroidSupportSupportVectorDrawable2320Library UP-TO-DATE      
:app:prepareComBignerdranchAndroidRecyclerviewMultiselect02Library UP-TO-DATE    
:app:prepareComFlipboardBottomsheetCommons150Library UP-TO-DATE        
:app:prepareComFlipboardBottomsheetCore150Library UP-TO-DATE         
:app:prepareComJoshdholtzSentrySentryAndroid121Library UP-TO-DATE       
:app:prepareComScottyabAescrypt001Library UP-TO-DATE           
:app:prepareIoReactivexRxandroid101Library UP-TO-DATE          
:app:prepareOrgSolovyevAndroidViewsLinearLayoutManager05Library UP-TO-DATE     
:app:prepareReleaseDependencies                
:app:compileReleaseAidl UP-TO-DATE               
:app:compileReleaseRenderscript UP-TO-DATE             
:app:generateReleaseBuildConfig UP-TO-DATE             
:app:generateReleaseAssets UP-TO-DATE              
:app:mergeReleaseAssets UP-TO-DATE               
:app:generateReleaseResValues UP-TO-DATE              
:app:generateReleaseResources UP-TO-DATE              
:app:mergeReleaseResources UP-TO-DATE              
:app:processReleaseManifest UP-TO-DATE              
:app:processReleaseResources UP-TO-DATE              
:app:generateReleaseSources UP-TO-DATE              
:app:compileReleaseJavaWithJavac UP-TO-DATE             
:app:compileRetrolambdaRelease UP-TO-DATE             
:app:compileReleaseNdk UP-TO-DATE               
:app:compileReleaseSources UP-TO-DATE              
:app:lintVitalRelease                  
:app:processReleaseJavaRes UP-TO-DATE              
:app:transformResourcesWithMergeJavaResForRelease UP-TO-DATE         
:app:transformClassesAndResourcesWithProguardForRelease          
ProGuard, version 5.2.1                  
Reading input...                    
Reading program jar commons-codec/commons-codec/1.3/fd32786786e2adb664d5ecc965da47629dca14ba 
Reading program jar me.tatarka/gradle-retrolambda/3.2.4/54ada546a04c36af9a2c7215c17f599e42bd 
Reading program jar com.michaelpardo/activeandroid/3.1.0-SNAPSHOT/4ab7b0182975bc57c49efc5e0b 
Reading program jar javax.annotation/javax.annotation-api/1.2/479c1e06db31c432330183f5cae684 
Reading program jar com.github.bumptech.glide/glide/3.7.0/9e9eeaf9948ee4d6c3ab354e8dc14368f1 
Reading program jar com.squareup.okhttp3/logging-interceptor/3.0.1/1d232df84491c0453e0770025 
Reading program jar com.squareup.okhttp3/okhttp/3.0.1/b34c1f2d993044656e87f88970b6818e99e886 
Reading program jar com.squareup.retrofit2/adapter-rxjava/2.0.0-beta4/bd49baf667542c7d06f71e 
Reading program jar com.squareup.retrofit2/converter-gson/2.0.0-beta4/de5935a367ba5e343e9df7 
Reading program jar com.squareup.okio/okio/1.6.0/98476622f10715998eacf9240d6b479f12c66143/ok 
Reading program jar com.squareup.retrofit2/retrofit/2.0.0-beta4/739e00dea1f0ac04fdb9b6160d66 
Reading program jar m2repository/com/android/support/support-annotations/23.2.0/support-anno 
Reading program jar se.akerfeldt/okhttp-signpost/1.1.0/544600ae042f8fc113acb612ef30c69144b68 
Reading program jar com.google.code.gson/gson/2.4/695b63d702f505b9b916e02272e3b6381bade7f/gs 
Reading program jar com.jakewharton/butterknife/7.0.1/d5d13ea991eab0252e3710e5df3d6a9d4b21d4 
Reading program jar oauth.signpost/signpost-core/1.2.1.2/bf95955dcf3d5a78c201e49b0c336787ea7 
Reading program jar io.reactivex/rxjava/1.1.0/748f0546d5c3c27f1aef07270ffea0c45f0c42a4/rxjav 
Reading program jar /app/build/intermediates/exploded-aar/com.android.support/design/23.2.0/ 
Reading program jar /app/build/intermediates/exploded-aar/io.reactivex/rxandroid/1.0.1/jars/ 
Reading program jar /app/build/intermediates/exploded-aar/com.scottyab/aescrypt/0.0.1/jars/c 
Reading program jar /app/build/intermediates/exploded-aar/com.joshdholtz.sentry/sentry-andro 
Reading program jar /app/build/intermediates/exploded-aar/org.solovyev.android.views/linear- 
Reading program jar /app/build/intermediates/exploded-aar/com.bignerdranch.android/recyclerv 
Reading program jar /app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/2 
Reading program jar /app/build/intermediates/exploded-aar/com.android.support/animated-vecto 
Reading program jar /app/build/intermediates/exploded-aar/com.android.support/support-vector 
Reading program jar /app/build/intermediates/exploded-aar/com.android.support/recyclerview-v 
Reading program jar /app/build/intermediates/exploded-aar/com.flipboard/bottomsheet-commons/ 
Reading program jar /app/build/intermediates/exploded-aar/com.flipboard/bottomsheet-core/1.5 
Reading program jar /app/build/intermediates/exploded-aar/com.android.support/support-v4/23. 
Reading program jar /app/build/intermediates/exploded-aar/com.android.support/support-v4/23. 
Reading program jar /app/build/intermediates/transforms/mergeJavaRes/release/jars/2/1f/main. 
Reading program directoryapp/build/intermediates/classes/release] (filtered)     
Reading library jar [/Android/sdk/platforms/android-23/android.jar]       
Reading library jar [/Android/sdk/platforms/android-23/optional/org.apache.http.legacy.jar] 
Note: duplicate definition of library class [android.net.http.SslError]      
Note: duplicate definition of library class [android.net.http.SslCertificate]    
Note: duplicate definition of library class [android.net.http.SslCertificate$DName]   
Note: duplicate definition of library class [org.apache.commons.codec.language.DoubleMetapho 
Note: duplicate definition of library class [org.apache.commons.codec.language.Soundex]  
Note: duplicate definition of library class [org.apache.commons.codec.language.Metaphone] 
Note: duplicate definition of library class [org.apache.commons.codec.language.RefinedSounde 
Note: duplicate definition of library class [org.apache.commons.codec.language.DoubleMetapho 
Note: duplicate definition of library class [org.apache.commons.codec.binary.BinaryCodec] 
Note: duplicate definition of library class [org.apache.commons.codec.binary.Base64]   
Note: duplicate definition of library class [org.apache.commons.codec.binary.Hex]   
Note: duplicate definition of library class [org.apache.commons.codec.Encoder]    
Note: duplicate definition of library class [org.apache.commons.codec.net.URLCodec]   
Note: duplicate definition of library class [org.apache.commons.codec.net.BCodec]   
Note: duplicate definition of library class [org.apache.commons.codec.net.QCodec]   
Note: duplicate definition of library class [org.apache.commons.codec.net.QuotedPrintableCod 
Note: duplicate definition of library class [org.apache.commons.codec.net.RFC1522Codec]  
Note: duplicate definition of library class [org.apache.commons.codec.BinaryEncoder]   
Note: duplicate definition of library class [org.apache.commons.codec.StringEncoderComparato 
Note: duplicate definition of library class [org.apache.commons.codec.DecoderException]  
Note: duplicate definition of library class [org.apache.commons.codec.BinaryDecoder]   
Note: duplicate definition of library class [org.apache.commons.codec.EncoderException]  
Note: duplicate definition of library class [org.apache.commons.codec.StringEncoder]   
Note: duplicate definition of library class [org.apache.commons.codec.StringDecoder]   
Note: duplicate definition of library class [org.apache.commons.codec.Decoder]    
Note: duplicate definition of library class [org.apache.http.conn.scheme.HostNameResolver] 
Note: duplicate definition of library class [org.apache.http.conn.scheme.SocketFactory]  
Note: duplicate definition of library class [org.apache.http.conn.ConnectTimeoutException] 
Note: duplicate definition of library class [org.apache.http.params.HttpParams]    
Reading library jar [/lib/libGoogleAnalytics.jar]           
Warning:Exception while processing task java.io.IOException: Can't read [/lib/libGoogleAnaly 
:app:transformClassesAndResourcesWithProguardForRelease FAILED        
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. 
> java.io.IOException: Can't read [/lib/libGoogleAnalytics.jar] (No such file or directory) 
Information:BUILD FAILED                  
Information:Total time: 8.506 secs               
Information:1 error                   
Information:1 warning                  
Information:See complete output in console  

最奇怪的是我沒有使用Apache庫或GoogleAnalytics庫。我張貼的gradle我的文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.5.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
     classpath 'me.tatarka:gradle-retrolambda:3.2.4' 
     classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2' 
     classpath 'com.android.tools.build:gradle:1.5.0' 
    } 

    // Exclude the version that the android plugin depends on. 
    configurations.classpath.exclude group: 'com.android.tools.external.lombok' 
} 

allprojects { 
    repositories { 
     jcenter() 
     mavenCentral() 
     maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
    } 

} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

而且

apply plugin: 'com.android.application' 
apply plugin: 'me.tatarka.retrolambda' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.something.sythg" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 

    } 
    buildTypes { 
     debug { 
      buildConfigField "Boolean", "DEBUG_MODE", "true" 
     } 
     release { 
      buildConfigField "Boolean", "DEBUG_MODE", "false" 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 

    packagingOptions { 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 

    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4' 
    compile 'com.android.support:appcompat-v7:23.2.0' 
    compile 'com.android.support:design:23.2.0' 
    compile 'com.android.support:support-v4:23.2.0' 
    compile 'com.android.support:recyclerview-v7:23.2.0' 
    compile 'com.jakewharton:butterknife:7.0.1' 
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' 
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1' 
    compile 'se.akerfeldt:okhttp-signpost:1.1.0' 
    compile 'io.reactivex:rxjava:1.0.14' 
    compile 'io.reactivex:rxandroid:1.0.1' 
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4' 
    compile 'me.tatarka:gradle-retrolambda:3.2.4' 
    compile 'oauth.signpost:signpost-core:1.2.1.2' 
    compile 'com.scottyab:aescrypt:0.0.1' 
    compile 'com.joshdholtz.sentry:sentry-android:1.2.1' 
    compile 'com.android.support:support-annotations:23.2.0' 
    compile 'javax.annotation:javax.annotation-api:1.2' 
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' 
    compile 'org.solovyev.android.views:linear-layout-manager:[email protected]' 
    compile 'com.github.bumptech.glide:glide:3.7.0' 
    compile 'com.bignerdranch.android:recyclerview-multiselect:+' 
    compile 'com.flipboard:bottomsheet-core:1.5.0' 
    compile 'com.flipboard:bottomsheet-commons:1.5.0' // optional 
} 

而且我proguard-rules.pro

# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in /Users/diegobarrerarodriguez/Library/Android/sdk/tools/proguard/proguard-android.txt 
# You can edit the include path and order by changing the proguardFiles 
# directive in build.gradle. 
# 
# For more details, see 
# http://developer.android.com/guide/developing/tools/proguard.html 

# Add any project specific keep options here: 

# If your project uses WebView with JS, uncomment the following 
# and specify the fully qualified class name to the JavaScript interface 
# class: 
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { 
# public *; 
#} 

########--------Retrofit + RxJava--------######### 
-dontwarn retrofit.** 
-keep class retrofit.** { *; } 
-dontwarn sun.misc.Unsafe 
-dontwarn com.octo.android.robospice.retrofit.RetrofitJackson** 
-dontwarn retrofit.appengine.UrlFetchClient 
-keepattributes Signature 
-keepattributes Exceptions 
-keepclasseswithmembers class * { 
    @retrofit.http.* <methods>; 
} 
-keep class com.google.gson.** { *; } 
-keep class com.google.inject.** { *; } 
-keep class org.apache.http.** { *; } 
-keep class org.apache.james.mime4j.** { *; } 
-keep class javax.inject.** { *; } 
-keep class retrofit.** { *; } 
-dontwarn org.apache.http.** 
-dontwarn android.net.http.AndroidHttpClient 
-dontwarn retrofit.** 

-dontwarn sun.misc.** 

-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { 
    long producerIndex; 
    long consumerIndex; 
} 

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { 
    long producerNode; 
    long consumerNode; 
} 


# ALSO REMEMBER KEEPING YOUR MODEL CLASSES 
-keep class com.something.sthg.model.** { *; } 

################### Retrolambda 
-dontwarn java.lang.invoke.* 

################### ButterKnife 
-keep class butterknife.** { *; } 
-dontwarn butterknife.internal.** 
-keep class **$$ViewBinder { *; } 

-keepclasseswithmembernames class * { 
    @butterknife.* <fields>; 
} 

-keepclasseswithmembernames class * { 
    @butterknife.* <methods>; 
} 

################### ActiveAndroid 
-keep class com.activeandroid.** { *; } 
-keep class com.activeandroid.**.** { *; } 
-keep class * extends com.activeandroid.Model 
-keep class * extends com.activeandroid.serializer.TypeSerializer 

################### Signpost OAuth 
-libraryjars /lib/libGoogleAnalytics.jar 
-libraryjars /lib/signpost-commonshttp4-1.2.1.1.jar 
-libraryjars /lib/signpost-core-1.2.1.1.jar 
-dontwarn org.apache.commons.codec.binary.Base64 

################### Annotation 
-dontwarn javax.annotation.** 
-dontwarn javax.inject.** 
-dontwarn sun.misc.Unsafe 

################### Apache 
-keep class org.apache.http.** { *; } 
-keep class org.apache.commons.codec.** { *; } 
-keep class org.apache.commons.logging.** { *; } 
-keep class android.net.compatibility.** { *; } 
-keep class android.net.http.** { *; } 
-dontwarn org.apache.http.** 
-dontwarn android.webkit.** 

回答

2

我找到了答案,只需使用-dontnote每一個錯誤。像這樣:

-dontnote android.net.http.** 
-dontnote org.apache.commons.** 
-dontnote org.apache.http.**