Android Proguard-使用Proguard-Android-optimize.txt生成失败

Android Proguard-使用Proguard-Android-optimize.txt生成失败,android,proguard,android-multidex,Android,Proguard,Android Multidex,我正在尝试构建一个启用proguard的项目。如果我使用“proguard android.txt”作为默认规则文件,它可以正常工作,但使用“proguard android optimize.txt”失败,这是可以理解的,但我不理解我得到的错误: Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.internal.LoggedErrorException: Failed to

我正在尝试构建一个启用proguard的项目。如果我使用“proguard android.txt”作为默认规则文件,它可以正常工作,但使用“proguard android optimize.txt”失败,这是可以理解的,但我不理解我得到的错误:

    Error:Execution failed for task ':app:dexDebug'.
    > com.android.ide.common.internal.LoggedErrorException: Failed to run command:
        /Users/sayed/Library/Android/sdk/build-tools/21.1.2/dx -JXmx4g --dex --no-optimize 
--multi-dex --main-dex-list /Users/sayed/workspace/git/myproject/app/build/intermediates/multi-dex/debug/maindexlist.txt --multi-dex --output /Users/sayed/workspace/git/myproject/app/build/intermediates/dex/debug --input-list=/Users/sayed/workspace/git/myproject/app/build/intermediates/tmp/dex/debug/inputList.txt
      Error Code:
        1
      Output:
还有一个很长的描述,超过了身体角色的SO限制

这是我的gradle档案-

apply plugin: 'com.android.application'
apply plugin: 'robolectric'
apply plugin: 'android'
apply plugin: 'newrelic'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.mypackage"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 54
        versionName "2.002"
        multiDexEnabled true
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
        resConfigs "en", "fr" , "ar"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        androidTest {
            setRoot('src/test')
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    repositories{
        maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' }
    }

    repositories {
        mavenCentral()
    }

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile 'com.android.support:appcompat-v7:21.+'
        compile 'com.github.chrisbanes.photoview:library:1.2.3'
        compile 'com.etsy.android.grid:library:1.0.5'
        compile 'com.facebook.android:facebook-android-sdk:3.21.1'
        compile 'com.google.android.gms:play-services-base:6.5.+'
        compile 'com.google.android.gms:play-services-wallet:6.5.+'
        compile 'com.google.android.gms:play-services-ads:6.5.+'
        compile 'com.google.android.gms:play-services-maps:6.5.+'
        compile 'com.google.android.gms:play-services-drive:6.5.+'
        compile 'com.google.android.gms:play-services-appindexing:6.5.+'
        compile 'com.google.android.gms:play-services-location:6.5.+'
        compile 'com.google.android.gms:play-services-identity:6.5.+'
        compile 'com.google.android.gms:play-services-plus:6.5.+'
        compile 'com.android.support:multidex:1.0.+'
        compile project(':Adjust')
        compile project(':aFileChooser-cbccac1d1cb74a6d57d25c5ded61e4bf4fc40c91')
        compile 'com.parse.bolts:bolts-android:1.+'
        compile 'com.squareup.picasso:picasso:2.4.0'
        compile 'com.android.support:recyclerview-v7:+'
        compile (group: 'com.zendesk', name: 'sdk', version: '1.0.0.1'){
            //    exclude group:'picasso'
        }
        compile 'com.android.support:recyclerview-v7:+'
        compile 'com.newrelic.agent.android:android-agent:4.+'
        compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
        compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.2'
        compile 'com.fasterxml.jackson.core:jackson-core:2.4.2'


        /*compile ('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
            exclude module: 'commons-logging'
            exclude module: 'httpcore'
            exclude module: 'httpclient'
        }
        compile ('oauth.signpost:signpost-core:1.2.1.2') {
            exclude module: 'commons-codec'
        }*/

        androidTestCompile 'org.robolectric:robolectric:2.4'
        androidTestCompile('junit:junit:4.12')
        androidTestCompile('org.mockito:mockito-core:1.10.19')

    }

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

}

robolectric {
    include '**/*Test.class'
}
这是proguard-rules.pro文件-

-libraryjars libs

# We only want obfuscation
#-keepattributes InnerClasses,Signature

# Sdk
-keep public interface com.zendesk.sdk.** { *; }
-keep public class com.zendesk.sdk.** { *; }

# Gson
-keep interface com.google.gson.** { *; }
-keep class com.google.gson.** { *; }


# Retrofit
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**

-dontwarn rx.**
-dontwarn retrofit.**
-dontwarn okio.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}

# NewRelic
-keep class com.newrelic.** { *; }
-dontwarn com.newrelic.**
-keepattributes Exceptions, Signature, InnerClasses

# Jackson
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepnames class com.fasterxml.jackson.** { *; }
 -dontwarn com.fasterxml.jackson.databind.**
 -keep class org.codehaus.** { *; }
 -keepclassmembers public final enum org.codehaus.jackson.annotate.JsonAutoDetect$Visibility {
 public static final org.codehaus.jackson.annotate.JsonAutoDetect$Visibility *; }
-keep public class mypackage.parsers.KombiJacksonParser.** {
  public void set*(***);
  public *** get*();
}

#Picasso
-dontwarn com.squareup.okhttp.**

# apache
-dontwarn org.mortbay.**
-dontwarn org.slf4j.**
-dontwarn org.apache.log4j.**
-dontwarn org.apache.commons.logging.**
-dontwarn org.apache.commons.codec.binary.**
然后这最后——

EXCEPTION FROM SIMULATION:
    expected type int but found com.c.fd
    ...at bytecode offset 000000a8
    locals[0000]: <addr:002a>
    locals[0001]: I
    ...while working on block 00a8
    ...while working on method <clinit>:()V
    ...while processing <clinit> ()V
    ...while processing com/c/fd.class
    1 error; aborting
模拟异常: 应为int类型,但找到com.c.fd …字节码偏移量000000 A8处 本地人[0000]: 本地人[0001]:I …在块00a8上工作时 …在处理方法时:()V …在处理()V时 …在处理com/c/fd.class时 1错误;正在中止
根据您上面的描述,我猜您是在Android Studio工作,对吗?您可以发布您的gradle文件吗?谢谢。我已经更新了我的问题,您可以发布错误输出的相关部分吗?使用
proguard Android.txt
proguard Android optimize.txt
是否正确?尝试添加“编译'com.android.support:support annotations:21.0.+“到你的gradle文件…是的,这很好。我现在只是测试它的调试构建类型。android Studio有这两个proguard默认模板,你可以使用。
EXCEPTION FROM SIMULATION:
    expected type int but found com.c.fd
    ...at bytecode offset 000000a8
    locals[0000]: <addr:002a>
    locals[0001]: I
    ...while working on block 00a8
    ...while working on method <clinit>:()V
    ...while processing <clinit> ()V
    ...while processing com/c/fd.class
    1 error; aborting