Generate Signed APK: Errors while building APK Android Studio

后端 未结 9 1955
无人共我
无人共我 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:42

    Maybe one of your libraries (especially libraries which can use networking(httpClient, okHttp etc)) conflicts.. Try adding all of your libraries to a new project(do not add any code or component to your project).. If error occurs in that project too so the problem is in one of the libraries.. Try to uncomment libraries one by one..

    0 讨论(0)
  • 2021-02-12 22:47

    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'
            }
        }
    }
    
    0 讨论(0)
  • 2021-02-12 22:47

    Try to generate signed APK using terminal by gradle command see your stack trace that will give you detailed log where has the problem.

    In Windows

    $gradle clean

    $  gradle --stacktrace assembleRelease
    

    In Ubuntu

    $./gradlew clean

    $./gradlew --stacktrace assembleRelease 
    

    if you have still problem post you stack trace here

    0 讨论(0)
提交回复
热议问题