无法使用minifyEnabled true在调试和发布模式下运行apk

时间:2018-08-02 05:31:49

标签: android obfuscation

我无法在调试和发布模式下使用minifyEnabled true运行apk。我引用了以下链接,但没有一个对我有用。

1。Error:Execution failed for task ':app:transformClassesWithDexForDebug' in android studio

下面是我的应用程序build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    defaultConfig {
        applicationId 'XX.XX.XXX'
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 9
        versionName "1.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    sourceSets.main {
        jni.srcDirs = [] //disable automatic ndk-build call
        jniLibs.srcDir 'src/main/libs' //integrate your libs from libs instead of jniLibs
    }
    dexOptions {
        javaMaxHeapSize "4g" //specify the heap size for the dex process
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }


    }
    productFlavors {
    }
    lintOptions {
        checkReleaseBuilds false
    }
    packagingOptions {
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'

    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    //    compile files('libs/maflogonimo-1.210.3.jar')
    compile project(':android-logging-log4j-1.0.3')
    compile project(':log4j-1.2.17')
    compile files('libs/gson-2.6.2.jar')
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.android.gms:play-services-auth:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.esri.arcgis.android:arcgis-android:10.2.8-1'
    //GIS

    compile(name:'ClientHubSLL-3.16.1', ext:'aar')
    compile(name:'ClientLog-3.16.1', ext:'aar')
    compile(name:'Common-3.16.1', ext:'aar')
    compile(name:'Connectivity-3.16.1', ext:'aar')
    compile(name:'CoreServices-3.16.1', ext:'aar')
    compile(name:'DataVaultLib-3.16.1', ext:'aar')
    compile(name:'E2ETrace-3.16.1', ext:'aar')
    compile(name:'HttpConvAuthFlows-3.16.1', ext:'aar')
    compile(name:'HttpConversation-3.16.1', ext:'aar')
    compile(name:'MAFLogger-3.16.1', ext:'aar')
    compile(name:'MAFLogonCore-3.16.1', ext:'aar')
    compile(name:'ODataAPI-3.16.1', ext:'aar')
    compile(name:'ODataOnline-3.16.1', ext:'aar')
    compile(name:'Request-3.16.1', ext:'aar')
    compile(name:'SupportabilityFacade-3.16.1', ext:'aar')

    compile(name:'MAFCalendar-3.16.1', ext:'aar')
    compile(name:'MAFLocaleAwareControls-3.16.1', ext:'aar')
    compile(name:'MAFLogViewer-3.16.1', ext:'aar')
    compile(name:'MAFSettingScreen-3.16.1', ext:'aar')
    compile(name:'MAFTreeView-3.16.1', ext:'aar')
    compile(name:'MAFUIComponents-3.16.1', ext:'aar')
    compile(name:'XscriptParser-3.16.1', ext:'aar')
    compile(name:'MAFLogonUI-3.16.1', ext:'aar')
    compile(name:'MobilePlace-3.16.1', ext:'aar')

}

apply plugin: 'com.google.gms.google-services'

下面是我的proguard-rules.pro文件

-renamesourcefileattribute SourceFile
-keepattributes SourceFile, LineNumberTable
-keepattributes Exceptions, Signature

-keepattributes EnclosingMethod
-keepattributes InnerClasses

-keep class org.javarosa.** { *; }
-keep class com.sap.** { *; }

-keep class jcifs.** { *; }


-dontwarn com.google.**
-dontwarn org.apache.**
-dontwarn com.sap.**
-dontwarn au.com.bytecode.**
-dontwarn org.joda.**
-dontwarn android.content.**
-dontwarn android.graphics.**
-dontwarn android.util.**
-dontwarn android.view.**

-dontwarn javax.servlet.**
-dontwarn jcifs.http.**
-dontwarn org.codehaus.**

警告和错误在下面,

Warning:(291, 26) '_' used as an identifier
(use of '_' as an identifier might not be supported in releases after Java SE 8)

    Error:Error converting bytecode to dex:
    Cause: java.lang.RuntimeException: Exception parsing classes
    Error:1 error; aborting
    :app:transformClassesWithDexForDebug FAILED
    Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_161\bin\java.exe'' finished with non-zero exit value 1

请帮助我。预先感谢。

0 个答案:

没有答案