Android Studio will provide the options to use Proguard if it is enabled. However, some classes or files do NOT like to be optimised and obfuscated. In particular Javascript files and reference to classes that do not exist in the path. Here is an example of how the error message may appear when building the signed APK on Linux & MS Windows.
Linux
Error:Execution failed for task ':app:packageMinirelease'.
> Unable to compute hash of /usr/development/BakersPercentage/app/build/intermediates/classes-proguard/minirelease/classes.jar
MS Windows
Error from proguard during build |
Since the problem is a warning on GMS packages, I resolved on Android Studio 1.4 as follows;
Step 1: Verify project works
Open the project and make sure it can build without errors.
Step 2: Edit build.gradle (Module: app)
Copy the existing release build type and paste as a new build release named minirelease (or any name you fancy).
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
minirelease {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
Step 3: Edit proguard-rules.pro
Add the following lines
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
Step 4: Build Signed APK
In Android Studio menu, choose Build-> Clean Project
Build-> Generate Signed APK...
Enter Key details and click Next.
In Build Type: choose minirelease.
Click Finish.
Done.
1 comment:
Hi,
I see your post that's in clearly define the process of android mobile apps
Android Apps developer
Post a Comment