Flutter Release apk is not working properly?

后端 未结 8 1020
深忆病人
深忆病人 2021-02-07 07:41

I had run this flutter build apk to release my App. Now I had build verison 2 of that.

Now again I want to release my version 2 App.To get the release apk

相关标签:
8条回答
  • 2021-02-07 08:10

    The problem was that flutter build automatically shrinks the code with R8. flutter build --no-shrink solved the problem. I guess I need to add all required exceptions to the proguard-rules.pro file.

    Building apk using the below commands.

    1. Enter cd <app dir> (Replace with your application’s directory.)

    2. flutter build apk --split-per-abi --no-shrink (The flutter build command defaults to --release .)

    Removing the --split-per-abi flag results in a fat APK that contains your code compiled for all the target ABIs. Such APKs are larger in size than their split counterparts, causing the user to download native binaries that are not applicable to their device’s architecture.

    0 讨论(0)
  • 2021-02-07 08:11

    When you are creating new Flutter project (from Android Studio menu), in file:

    /android/app/build.gradle
    

    which is there:

    you have:

    buildTypes {
        release {
            signingConfig signingConfigs.debug    //   <--- HERE YOU ARE USING DEBUG KEY
        }
    }
    

    Which means that release build (e.g. triggered from menu Build -> Flutter -> Build APK) will use debug key for signing.

    Full build.gradle file (created by Android Studio):

    Solution

    Change from:

    signingConfig signingConfigs.debug
    

    to:

    signingConfig signingConfigs.release
    

    so (in build.gradle) you should have:

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    
    0 讨论(0)
提交回复
热议问题