Reputation: 43
The debug version of the app is fine on the emulator and on my android device. Even installing the app-debug.apk is fine. However, when I 'flutter build apk', the app-release.apk comes with weird bugs in it and buttons and some other animations stop performing their tasks. I couldn't find out anything about it online. Has anyone of you faced this issue? Could it be an issue with Provider State Management? I don't see how because the app-debug.apk works perfectly fine.
It started on Flutter master, but then I tried each one of the other channels and all had the same issue.
Flutter 1.18.0-6.0.pre.106 • channel master • Tools • Dart 2.9.0 (build 2.9.0-1.0.dev a12c36dd97)
Flutter 1.12.13+hotfix.9 • channel stable • Tools • Dart 2.7.2
Flutter 1.17.0 • channel beta • Tools • Dart 2.8.0 (build 2.8.0-dev.18.0 eea9717938)
Flutter 1.18.0-dev.5.0 • channel dev • Tools • Dart 2.8.0 (build 2.8.0-dev.20.0 89b0f67261)
On all the emulators (3-4) and devices (2) I tried, the release version either didn't open up, or if it did open it had bugs inside it.
It's thousands of lines of code and I don't know where the error is but here is the link to the repo anyway: https://github.com/burhanhaq/PomodoroApp/tree/master/lib
EDIT: Figured out the problem. I had an error with a controller in debug mode which I didn't take care of. I was calling setstart() during rebuilding/repainting of a widget and that was an error.
Upvotes: 0
Views: 1429
Reputation: 4316
Try to disable R8, which is the new code shrinker from Google, and it’s enabled by default. It can change your code while optimizing it and it may cause the app to fail in some specific projects like yours. To do that, pass the --no-shrink
flag to flutter build apk
or flutter build appbundle
. You can read the full docs about R8 here.
The second option that You can try is to build the apk through Android Studio IDE. When you open Android Studio open /android
folder as a project, then try to build the apk through the IDE instead of Terminal.
Upvotes: 0
Reputation: 85
You should try disabling progaurd and minifyEnabled. From build.gradle file which sits inside /android/app/
This may happen as the progaurd performs it's actions in release version by obfuscating your code which may sometimes break your build.
Upvotes: 1
Reputation: 483
The way you are building apk is a fat APK, try using the following command in terminal it will reduce the basic bugs because it will be built for specific devices
flutter build apk --split-per-abi
you can read more about it here Build and Release Android app
Upvotes: 1