How to build signed apk from Android Studio for Fl

2019-07-31 04:56发布

问题:

Is there a way to build apk for Flutter from Android Studio.

I have seen this guideline: https://flutter.dev/docs/deployment/android
But here flutter console is used to build apk.

回答1:

  1. Go to

    File > Project Structure

  2. Select your-app-name under module.

    Click on your app and then click +

  3. Under the add tab select android

  4. Now you can see generate signed apk/bundle enabled under build tab



回答2:

As per DanyPata For flutter you have to set the signing file and then run flutter build APK. It's quite important to run the flutter command so that all the changes/libs added in flutter are also added in the Android project.

Step 1

Go to File - Project Structure and select app under Modules. NOTE: It probably won't be called app- It may be under whatever name you gave it when creating the project. Select the Signing tab.

You need to create a certificate so click the blue plus sign and fill in the blanks. When you finish this process then you head over to the Build Types tab and make sure you have two - debug and release, if you don't have release then again press the blue plus sign and create it.

For a release build, you will want to select the Signing Config you previously created and leave the rest as default.

Then to build your release APK go to Build on the top main bar, then Build Bundle(s) / APK(s) and select Build APK(s).

Keep a close eye on the Event Log to see when its complete and the path where APK was saved to.

Step 2

Update the gradle.build file. Make sure your project visibility is set to something like Project so you can see all the files in the file tree.

Head down to yourapp/src then open build.gradle.

Under, android add:

buildTypes {
    release {
        minifyEnabled false
        signingConfig signingConfigs.theNameForCertificateYouCreated
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

IMPORTANT: As a quick reminder and precaution, DO NOT lose the key it creates. Without this, you won't be able to update your application because the new release will need to be signed with the same key.



回答3:

Every times you run your app, it will generate apks.

You can find it in your project files :

yourProject\build\app\outputs\apk