I am unable to generate Signed APK using minifyEnabled true
and shrinkResources true
App Level : build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "......."
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations {
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
}
dependencies {
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
compile 'com.google.http-client:google-http-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-gson:1.20.0'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.github.clans:fab:1.6.2'
}
MessageView
Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComGithubClansFab162Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac
Note: .....YouTubeRecyclerViewFragment.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: ....GetPlaylistAsyncTask.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:proguardRelease UP-TO-DATE
:app:dexRelease
:app:shrinkReleaseResources
Removed unused resources: Binary resource data reduced from 741KB to 402KB: Removed 45%
Note: If necessary, you can disable resource shrinking by adding
android {
buildTypes {
release {
shrinkResources false
}
}
}
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of ....\app\build\intermediates\classes-proguard\release\classes.jar
Information:BUILD FAILED
Information:Total time: 7.45 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
In the menu bar, click Build > Generate Signed Bundle/APK. In the Generate Signed Bundle or APK dialog, select Android App Bundle or APK and click Next. Below the field for Key store path, click Create new. On the New Key Store window, provide the following information for your keystore and key, as shown in figure 2.
Difference Between Building an Android APK and Generating a Signed APK file. As for the developer, an unsigned APK file is developed mainly for local testing purposes. Furthermore, these APK files can be made publicly available. However, Google Play Store does not accept these files as unsigned APK files are not secure ...
To generate a signed APK file, open the Build menu from the toolbar and select Generate Signed Bundle/APK. This opens up a screen where you have to select between creating an Android App Bundle and creating an APK file.
A Keystore is basically a binary file that contains a set of private keys. Every App that we install using the Google Play App Store needs to be signed with a Keystore. The signed apk is simply the unsigned apk that has been signed via the JDK jarsigner tool.
You are getting
Removed unused resources: Binary resource data reduced from 741KB to 402KB: Removed 45%
Note: If necessary, you can disable resource shrinking by adding
android {
buildTypes {
release {
shrinkResources false
}
}
}
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.
Resource shrinking works only in conjunction with code shrinking.
minifyEnabled is an Android tool that will decrease the size of your application when you go to build it .
android {
buildTypes {
release {
shrinkResources true // This must be first
minifyEnabled true // This must be after shrinkResources
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
If you haven't already built your app using minifyEnabled for code shrinking, then try that before enabling shrinkResources, because you might need to edit your proguard-rules.pro file to keep classes or methods that are created or invoked dynamically before you start removing resources.
Please read official Guideline about Shrink Your Code and Resources
Advice
Use latest version
compileSdkVersion 25
buildToolsVersion '25.0.1'
targetSdkVersion 25
compile 'com.android.support:appcompat-v7:25.1.0' // set other 25.1.0
NOTE
YouTubeRecyclerViewFragment.java uses or overrides a deprecated API.
Use Alternate Latest Version .
First check whether you really need to use shrinkResources
If so, do as suggested in developers link https://developer.android.com/studio/build/shrink-code.html#shrink-resources mentioned above by IntelliJ Amiya, you have to use like below
android { buildTypes { release { shrinkResources true // -- always add this above minifyEnabled -- minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
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