Generate Signed APK: Errors while building APK Android Studio

后端 未结 9 1953
无人共我
无人共我 2021-02-12 22:20

I am unable to generate Signed APK using minifyEnabled true and shrinkResources true

App Level : build.gradle

buildscript {
            


        
9条回答
  •  隐瞒了意图╮
    2021-02-12 22:28

    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 .

提交回复
热议问题