Obfuscation (minifyEnabled true) not working in Debug and Release

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Obfuscation (minifyEnabled true) not working in Debug and Release



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 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
minifyEnabled true
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 files('libs/javarosa-libraries-2015-09-02.jar')
compile 'com.android.support:design:23.4.0'
//compile 'com.android.support:multidex:1.0.1'
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.android.gms:play-services:10.0.1'

// compile 'com.google.android.gms:play-services-fcm:9.6.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
// compile 'com.viewpagerindicator:library:2.4.1@aar'
//compile files('libs/hellocharts-library-1.5.8.jar')
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 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.**



Below exception while running from command line


cause: java.lang.RuntimeException: Exception parsing classes
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
at com.android.dx.command.dexer.Main.processClass(Main.java:752)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
at com.android.dx.command.dexer.Main.run(Main.java:275)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Caused by: com.android.dx.cf.iface.ParseException: bad descriptor: charOffset
at com.android.dx.cf.direct.AttributeListParser.parse(AttributeListParser.java:156)
at com.android.dx.cf.direct.AttributeListParser.parseIfNecessary(AttributeListParser.java:115)
at com.android.dx.cf.direct.AttributeListParser.getEndOffset(AttributeListParser.java:96)
at com.android.dx.cf.direct.MemberListParser.parse(MemberListParser.java:213)
at com.android.dx.cf.direct.MemberListParser.parseIfNecessary(MemberListParser.java:108)
at com.android.dx.cf.direct.MethodListParser.getList(MethodListParser.java:54)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:542)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.parseClass(Main.java:764)
at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
at com.android.dx.command.dexer.Main.processClass(Main.java:749)
... 12 more
Caused by: java.lang.IllegalArgumentException: bad descriptor: charOffset
at com.android.dx.rop.type.Type.intern(Type.java:330)
at com.android.dx.cf.direct.AnnotationParser.parseAnnotation(AnnotationParser.java:248)
at com.android.dx.cf.direct.AnnotationParser.parseAnnotations(AnnotationParser.java:223)
at com.android.dx.cf.direct.AnnotationParser.parseAnnotationsList(AnnotationParser.java:188)
at com.android.dx.cf.direct.AnnotationParser.parseParameterAttribute(AnnotationParser.java:127)
at com.android.dx.cf.direct.StdAttributeFactory.runtimeVisibleParameterAnnotations(StdAttributeFactory.java:666)
at com.android.dx.cf.direct.StdAttributeFactory.parse0(StdAttributeFactory.java:162)
at com.android.dx.cf.direct.AttributeFactory.parse(AttributeFactory.java:96)
at com.android.dx.cf.direct.AttributeListParser.parse(AttributeListParser.java:141)
... 25 more

16:35:57.798 [ERROR] [org.gradle.api.Project] 1 error; aborting
16:35:57.800 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:transformClassesWithDexForRelease'
16:35:57.801 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :app:transformClassesWithDexForRelease FAILED
16:35:57.804 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:transformClassesWithDexForRelease (Thread[Daemon worker,5,main]) completed. Took 1 mins 1.425 secs.
16:35:57.807 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker,5,main]] finished, busy: 14 mins 11.51 secs, idle: 0.078 secs
16:35:57.870 [ERROR] [org.gradle.BuildExceptionReporter]
16:35:57.871 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
16:35:57.872 [ERROR] [org.gradle.BuildExceptionReporter]
16:35:57.872 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
16:35:57.872 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:transformClassesWithDexForRelease'.
16:35:57.873 [ERROR] [org.gradle.BuildExceptionReporter] > 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 FilesJavajdk1.8.0_161binjava.exe'' finished with non-zero exit value 1
16:35:57.874 [ERROR] [org.gradle.BuildExceptionReporter]
16:35:57.875 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
16:35:57.877 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
16:35:57.878 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:35:57.878 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
16:35:57.880 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:35:57.880 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 14 mins 46.244 secs
16:35:57.930 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileHashes.bin (D:myJobCard_SourceCode.gradle2.10taskArtifactsfileHashes.bin)
16:35:57.931 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshots.bin (D:myJobCard_SourceCode.gradle2.10taskArtifactsfileSnapshots.bin)
16:35:57.932 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache taskArtifacts.bin (D:myJobCard_SourceCode.gradle2.10taskArtifactstaskArtifacts.bin)
16:35:57.933 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache outputFileStates.bin (D:myJobCard_SourceCode.gradle2.10taskArtifactsoutputFileStates.bin)
16:35:57.933 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on task history cache (D:myJobCard_SourceCode.gradle2.10taskArtifacts).
16:35:57.935 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache jarSnapshots.bin (C:UsersMY HOME.gradlecaches2.10jarSnapshotsjarSnapshots.bin)
16:35:57.935 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on jar snapshots cache (C:UsersMY HOME.gradlecaches2.10jarSnapshots).
16:35:57.937 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache classAnalysis.bin (C:UsersMY HOME.gradlecaches2.10classAnalysisclassAnalysis.bin)
16:35:57.937 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on class analysis cache (C:UsersMY HOME.gradlecaches2.10classAnalysis).
16:35:57.939 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_settings class cache for settings file 'D:myJobCard_SourceCodesettings.gradle' (C:UsersMY HOME.gradlecaches2.10scriptssettings_erwoxweslgmu8miqym6kcb1dtcp_settings).
16:35:57.939 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on settings class cache for settings file 'D:myJobCard_SourceCodesettings.gradle' (C:UsersMY HOME.gradlecaches2.10scriptssettings_erwoxweslgmu8miqym6kcb1dtsettings).
16:35:57.940 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_proj class cache for build file 'D:myJobCard_SourceCodebuild.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_7pkieelf3zpr7uf7k01l63rmxcp_proj).
16:35:57.940 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on proj class cache for build file 'D:myJobCard_SourceCodebuild.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_7pkieelf3zpr7uf7k01l63rmxproj).
16:35:57.940 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_proj class cache for build file 'D:myJobCard_SourceCodeandroid-logging-log4j-1.0.3build.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_7utva779gtlkclvebpnh750jkcp_proj).
16:35:57.941 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on proj class cache for build file 'D:myJobCard_SourceCodeandroid-logging-log4j-1.0.3build.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_7utva779gtlkclvebpnh750jkproj).
16:35:57.941 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_proj class cache for build file 'D:myJobCard_SourceCodeappbuild.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_56xn5xy2yld7cwkurxonzuovlcp_proj).
16:35:57.942 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on proj class cache for build file 'D:myJobCard_SourceCodeappbuild.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_56xn5xy2yld7cwkurxonzuovlproj).
16:35:57.942 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_proj class cache for build file 'D:myJobCard_SourceCodelog4j-1.2.17build.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_8bsoptu904i00rpm86ii2r5ihcp_proj).
16:35:57.942 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on proj class cache for build file 'D:myJobCard_SourceCodelog4j-1.2.17build.gradle' (C:UsersMY HOME.gradlecaches2.10scriptsbuild_8bsoptu904i00rpm86ii2r5ihproj).
16:35:57.944 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 0 (avg: 0.0 secs, total: 0.0 secs)
16:35:57.945 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 8 (avg: 0.006 secs, total: 0.049 secs)
16:35:57.946 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 2 resolution results binary files in 0.003 secs
16:35:57.946 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedRepositoryFactory] In-memory dependency metadata cache closed. Repos cached: 41, cache instances: 5, modules served from cache: 702, artifacts: 49
16:35:57.946 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-artifacts.bin (C:UsersMY HOME.gradlecachesmodules-2metadata-2.16module-artifacts.bin)
16:35:57.947 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-metadata.bin (C:UsersMY HOME.gradlecachesmodules-2metadata-2.16module-metadata.bin)
16:35:57.947 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache artifact-at-repository.bin (C:UsersMY HOME.gradlecachesmodules-2metadata-2.16artifact-at-repository.bin)
16:35:57.947 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on artifact cache (C:UsersMY HOME.gradlecachesmodules-2).
16:35:57.949 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Plugin Resolution Cache (C:UsersMY HOME.gradlecaches2.10plugin-resolution) was closed 0 times.
16:35:57.950 [DEBUG] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopping 0 compiler daemon(s).
16:35:57.950 [INFO] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopped 0 compiler daemon(s).
16:35:57.952 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has finished executing the build.
16:36:45.960 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientInputForwarder] Dispatching close input message: org.gradle.launcher.daemon.protocol.CloseInput@66269a8
16:36:45.966 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 17: dispatching class org.gradle.launcher.daemon.protocol.CloseInput
16:36:45.971 [INFO] [org.gradle.launcher.daemon.client.DaemonClient] Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:transformClassesWithDexForRelease'.] from daemon DaemonInfopid=22532, address=[dcdd43f4-9cff-4985-9851-6f1b9dfca80e port:65391, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]], idle=false, context=DefaultDaemonContext[uid=b61dca0a-e70c-4dec-98ed-b69fe929e57e,javaHome=C:Program FilesJavajdk1.8.0_161,daemonRegistryDir=C:UsersMY HOME.gradledaemon,pid=22532,idleTimeout=120000,daemonOpts=-Xmx4096m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant] (build should be done).
16:36:45.977 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Finished



I am using Android Studio 1.5.1.Is this Android studio version matters for obfuscation (minifyEnabled true) ?
Are there any online or offline tools for encrypting the APK ?
Please suggest me.
I have wasted a lot of time on this.
Please help me with this.Thanks in Advance.





Have you tried -keep class java.com.formsEngine.tasks.FormLoaderTask?
– Krypton
Aug 7 at 7:35


-keep class java.com.formsEngine.tasks.FormLoaderTask





Hi Krypton, Thank you for your response.I will try now...
– Naveen
Aug 7 at 9:05






It didn't worked Krypton...
– Naveen
Aug 7 at 9:19





Obfuscation in Android Studio
– RonTLV
Aug 7 at 9:26





@RonTLV, I have checked it.I am trying the same kind but it is not working...
– Naveen
Aug 7 at 9:33




3 Answers
3



Well... As you haven't mentioned yet, to the ant, to pro-guard your app, That's why it is not able to obfuscate it. Use explicitly useProguard true


useProguard true



Need a simple example of app gradle build file...? Find it below as it is of my project :


apply plugin: 'com.android.application'

android
compileSdkVersion 26
defaultConfig
applicationId "com.xxxxxxxxxxcccccccvvvvvv.apps.firebase"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildTypes
release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true




dependencies
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'



Now what it means in wording :
It will only obfuscate your code in release of your project; which means you have to build your release apk.


obfuscate



Here we go...



Hmmmm... Hope it helps



In the pro-guard rules files... Do not try to program it like code, just keep some classes which are not so important as :
-keep public class OpenSource



Thats it.



Most importantly you should and must as a beginner use default pro-guard file set by android studio or whichever your IDE; while creating the project. like :


proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'



It is a good habit to create a new sample project, learn how to implement any concept, once we are hands on it and cleared the concept..., Open the main project and implement it within..., As ... As of now , we are mastered the concept.



It is always recommended to use Android Studio than any other IDE as it is officially by google as android is.. And it must be latest and updated IDE with minimum api 26 enabled. as google made compulsory last week that to upload apps on google play apps must target api level 26.



Also it helps to your project to get it build error free as all the latest dependencies are there along with patches.





Hi Sandhya, Thanks for your response. I will definetly try this and let you know...If I add "minifyEnabled false" it is not obfuscating, if I add "minifyEnabled true" it is giving above exception as mentioned.
– Naveen
Aug 8 at 6:01






How much minifyEnabled can minify your code...? It is not as important as pro-guarding your code. obfuscation and minifying both are different. But as you mentioned your code is not getting obfuscated, i given the answer in much depth.
– sandhya sasane
Aug 8 at 6:08





I have edited my Question.Please check application build.gradle file.
– Naveen
Aug 8 at 6:12





Do not use pro-guard or minify for debug as it is intended for testing purpose. Use only in release; with standard proguard file. Look Edit 3
– sandhya sasane
Aug 8 at 6:25





Sure, It is giving same exception which I have mentioned even If I add "minifyEnabled true, useProguard true, shrinkResources true" in release mode.
– Naveen
Aug 8 at 6:35




Try to delete the .idea and .gradle directory under your project root directory and restart your Android Studio and re-sync your project. And change your build.gradle settings as below:


.idea


.gradle


build.gradle


android
...
compileSdkVersion 24
buildToolsVersion "24.0.0"

defaultConfig
...
targetSdkVersion 24
...

...



Double check all the libraries inside libs to see if you have any duplicate ones with compile xxx, because you have below library dependencies declaration.


libs


compile xxx


compile fileTree(include: ['*.jar'], dir: 'libs')



This may cause the duplicate inclusion of libraries, for example, compile files('libs/gson-2.6.2.jar'). Try to remove all the duplicate libraries.


compile files('libs/gson-2.6.2.jar')





hey I have tried but no luck, giving below exceptions Error:PARSE ERROR: Error:bad descriptor: charOffset Error:...while parsing attributes[2] Error:...while parsing methods[1] Error:...while parsing org/b/a/g.class Error:1 error; aborting Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: org.gradle.process.internal.ExecException: Process 'command 'C:Prgm FilesJavajdk1.8.0_161binjava.exe'' finished with non-zero exit value 1
– Naveen
Aug 9 at 6:31





It is different error from your original post which means another problem
– shizhen
Aug 9 at 9:30





com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: org.gradle.process.internal.ExecException: Process 'command 'C:Prgm FilesJavajdk1.8.0_161binjava.exe'' finished with non-zero exit value 1 - this Exception is same for both cases
– Naveen
Aug 9 at 10:13






The error of168 duplicate classs definition disappeared?
– shizhen
Aug 9 at 10:32





Use gradlew assembleRelease --info --debug to get more debug information about the error.
– shizhen
Aug 9 at 11:00


gradlew assembleRelease --info --debug



ever considered upgrading from Android Studio 1.5.1 to 3.1.3 ??


1.5.1


3.1.3



and I've double-checked, that this is not a question from a few years ago.



it reads bad descriptor: charOffset, which hints for errors in the build.gradle... most likely, that the referenced proguard-android-optimize.txt does not even exist within the file-system.


bad descriptor: charOffset


build.gradle


proguard-android-optimize.txt



you'd have to reference the ProGuard configuration rules alike:


proguardFile "$project.rootDir/proguard-rules.pro"
// proguardFile "$project.rootDir/some-more-rules.pro"
shrinkResources true
minifyEnabled true





Hi Martin, Thank you for your response.I have to change proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' to proguardFile "$project.rootDir/proguard-rules.pro" in app level build.gradle file ?
– Naveen
Aug 22 at 5:21






@Naveen yes, usually this would apply to the release build configuration (just make sure the file exists, where it is being referenced). and downloading a newer version of the IDE would make sense, because much changed since then.
– Martin Zeitler
Aug 22 at 5:25



release





I have checked in debug mode with above code which you mentioned, giving exception Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'. > java.io.FileNotFoundException: D:myJobCard_SourceCodeproguard-rules.pro (The system cannot find the file specified)
– Naveen
Aug 22 at 5:28





@Naveen you have to put that file there, or adjust the path, so that it can be found. here I have several .pro files, for example $project.rootDir/proguard/google.pro, so that I can organize these as rule-sets, in order to know where to look for.
– Martin Zeitler
Aug 22 at 5:28



.pro


$project.rootDir/proguard/google.pro





I have one ,pro file that is "proguard-rules.pro", located in app.Hope you will help me on this Martin.
– Naveen
Aug 22 at 5:34







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS