Chuyển đến nội dung chính

How to fix the bug: flutter app crash on released mode but work fine in debug mode.

When developing a Flutter application, I faced a weird bug. The app could run on debug mode and even when I used the command line: flutter run --release, the app worked fine. But when I tried compiling it by flutter build apk (flutter build ios) then flutter install, the crashed immediately when starting.
Finally, I discovered it was because the device was running 64-bit version of flutter/dart vm, while my app was targeting 32-bit version. I fixed by adding: 

defaultConfig {
       ...
        ndk {
            abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'armeabi-v8a', 'armeabi'
        }
}

To /app/build.gradle

Nhận xét

Bài đăng phổ biến từ blog này

The bug: A package may not list itself as a dependency

If you named your app with the same name as any packages in pubspec.yaml. When running: $ flutter packages get You will have the bug: "A package may not list itself as a dependency" For example, I created an app named firebase_messaging and in pubspec.yaml I also included the package named firebase_messaging To fix this, you have to change the name of your app.