# How to Export APK in Flutter

To export an APK (Android Package) file in Flutter, follow this step-by-step guide. This guide will allow you to generate a release version of your Flutter app and prepare it for distribution or installation on Android devices.

### Step 1: **Set Up Your Environment**

Make sure you have Flutter and Android Studio installed on your machine. You’ll also need an emulator or a connected Android device to test the APK.

* Make sure Android SDK and Android Studio are properly installed.
    
* Ensure that your Flutter project is working correctly.
    

You can verify your environment by running:

```typescript
flutter doctor
```

Fix any issues reported by `flutter doctor` before proceeding.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729115056161/0dfd04bd-af3f-4302-b172-036722712290.png align="center")

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Make sure your flutter is running in android emulator</div>
</div>

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729115205519/4d7493c2-0741-415b-96ab-edac80452ae2.png align="center")

### Step 2: **Configure Your App for Release**

Before exporting the APK, you need to configure your Flutter app for release mode.

1. **Update** `android/app/build.gradle`:
    
    * Open `android/app/build.gradle`.
        
    * Locate the `buildTypes` block and ensure the `release` block is properly set up. Here's a default release configuration:
        
    
    ```typescript
    android {
        compileSdkVersion 34
    
        defaultConfig {
            applicationId "com.example.myapp" //make sure the name is from your company and prohect name
            minSdkVersion 21
            targetSdkVersion 33
            versionCode 1
            versionName "1.0"
        }
    
        buildTypes {
            release {
                // Shrinks, optimizes, and obfuscates your code by default
                minifyEnabled true
                // Enables ProGuard for code obfuscation (optional)
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }
    ```
    
    ### Step 4: **Build the APK**
    

Now that the project is set up for release, you can generate the APK.

1. **Run the Flutter Build Command**: Run the following command in the terminal from your project’s root directory:
    
    ```typescript
    flutter build apk --release
    ```
    
    This command builds the release APK and stores it in the `build/app/outputs/flutter-apk` directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729116053174/16484eaf-f2e2-4ab0-8649-280807205548.png align="center")
    
      
    
2. **Check the APK**: The APK will be located at:
    
    ```typescript
    build/app/outputs/flutter-apk/app-release.apk
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729116823674/e37422da-ade2-4e5b-abb2-91d7588a8c92.png align="center")
    

### Step 5: **Test the APK on an Android Device**

1. Transfer the APK to your Android device via USB, email, or cloud storage.
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">In my case I use Telegram</div>
    </div>
    
2. Open the APK file on your device and install it.  
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729116610345/90f11d37-0dba-456f-82a7-fd9d024cc1bf.png align="center")
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">That’s All! I think this is simply exporting Flutter app to APK, If your Flutter app has many features I think you will encounter some issues but you can simply search for the error or fix soulotion by prompting CHAT GPT xD</div>
    </div>
