I have to protect my app by enabling Proguard obfuscation in Android Studio. I have searched for the process of how to apply it but i did not get any clear solution. When i try it, i always get an error. So can anyone tell me the clear steps to apply it in my app?
I am doing this by the following steps:
In Android Studio, open up an Android project.
Change to Project View.
Change the following line:
minifyEnable false
to minifyEnable true
Set ProGuard Rules(optional)
4.1 In Project View, select the proguard-rules.pro file.
4.2 Add in the following lines to tell ProGuard not to obfuscate certain classes.
-keepclassmembers class com.dom925.xxxx { public * }
Error that I am getting by following the steps are
Error:Execution failed for task ':app:packageRelease'. Unable to compute hash of D:\Android\Pojectname\app\build\intermediates\classes-proguard\release\classes.jar
ProGuard is a command-line tool that reduces app size by shrinking bytecode and obfuscates the names of classes, fields and methods. It's an ideal fit for developers working with Java or Kotlin who are primarily interested in an Android optimizer.
You can obfuscate Android code to provide security against reverse engineering. You can use the Android ProGuard tool to obfuscate, shrink, and optimize your code.
To enable ProGuard in Android Studio.
Below is the sample how to enable default ProGuard in Android Studio.
proguardFiles getDefaultProguardFile('proguard-android.txt')
to enable the default one. If you want to use your own proguard file then use the below rules.
buildTypes { release { debuggable false minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { debuggable true minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }
The link with ProGuard settings for Android and other settings are available in these links:
For more detail go through this link
I figured out the problem:
Open up the proguard-rules.pro for your project and add this to the bottom:
-dontwarn java.nio.file.Files -dontwarn java.nio.file.Path -dontwarn java.nio.file.OpenOption -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Basically how I solved it was this I tried to run my app in 'release' mode and got a bunch of errors similar to this guy here: https://github.com/square/okio/issues/144
I pretty much followed what he said and fixed it.
Hope this can help others with generating their APK's!
visit more detail here :
Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of /../AndroidStudioProjects/../classes.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With