0

I cannot able to run apk using minifyEnabled true in Debug and Release mode.I have referred below links but none worked for me.

1.Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease'

2.Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes - Android studio 2.0 beta 6

Below is my application build.gradle file

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'

Below is my proguard-rules.pro file

-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.**

Errors are as follows,

1.
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes


2.
Error:1 error; aborting
:app:transformClassesWithDexForDebug FAILED


3.
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

Please help me with this.Thanks in advance.

Naveen
  • 481
  • 2
  • 6
  • 23

1 Answers1

-1

Try after adding this to your proguard-rules.pro

-dontwarn javax.naming.**
-dontwarn javax.servlet.**
-dontwarn org.slf4j.**

If you are stuck with proguard. then do remove this for now.

 buildTypes {
        release {
          //  minifyEnabled false
          //  proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
          //  minifyEnabled false
          //  proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
  • 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 – Naveen Aug 02 '18 at 12:15
  • This is default error, you have to get detailed error, try using command line --stacktrace – Khemraj Sharma Aug 02 '18 at 12:23
  • by the way why did not you removed proguard setting, If you don't want waste time, proguard is to remove unused classes. But if you are stuck with something then just remove proguard. and don't minify – Khemraj Sharma Aug 02 '18 at 12:28
  • yes Khemraj, but cannot able to proguard the project if minifyEnabled to true – Naveen Aug 02 '18 at 12:31
  • See edited answer, comment all setting related to proguard. – Khemraj Sharma Aug 02 '18 at 12:33
  • I have to use Proguard Khemraj. – Naveen Aug 02 '18 at 12:34
  • I am not getting, why? – Khemraj Sharma Aug 02 '18 at 12:43
  • because I have to Obfuscate the Project – Naveen Aug 02 '18 at 12:48