9

I upgraded Flutter to 2.0.0 recently and am stuck with this issue. flutter run and flutter run --profile work perfectly well, but flutter run --release makes app crash after startup. There is no stacktrace, there is no error or warning, there is no build issue or verbose warning, no hint really. I googled a lot, but similar questions were answered like "try to remove this line" or "try to add that line". I couldn't find any clear steps on how to debug what's wrong.

What steps should I take to debug this issue and find the root cause instead of trying meaningless changes on code hoping some of them will eventually fix the issue?

3
  • I face a similar problem, and it was because of a package so you need to make sure that the packages you used don't have any additional code (for example in android build.gradle or AndroidManifest.xml) or if there is you have to implement it, it's not necessary the case but it might be. Mar 21, 2021 at 4:52
  • Have you tried flutter run --release -v?
    – RyanNa
    Mar 23, 2021 at 8:05
  • Yes, but found nothing useful in the log :/
    – aleskva
    Mar 24, 2021 at 21:36

6 Answers 6

6
+50

Use adb logcat

OR

Enable debugging in release build, by modifying your android/app/build.gradle like this

buildTypes {
    release {
        debuggable true
        shrinkResources false
        minifyEnabled false
        ...
    }
}
2

When the error is code related and not in flutter itself sentry should help.

Sentry's Flutter SDK enables automatic reporting of errors, messages, and exceptions.

You can import it just as any other package

dependencies:
  sentry_flutter: ^4.0.6

and configure it as early as possible in you app

import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
  await SentryFlutter.init(
    (options) => options.dsn = 'put_your_public_key_here',
    appRunner: () => runApp(MyApp()),
  );
}

To get your public key you just have to sign up on sentry.io and create a flutter project, no need to search for your key your it should be in the example code, it wont let you pass that point without initialiting it so you can't miss it. The docs regarding flutter can be found here.

1

You can Use Firebase Analytics to see error logs from your released devices from firebase. Previously it was named as Fabric.

Or you can create your own log tracker, write the logs in a file and upload the log to your server.

You can give options to user to capture log and send to server within "Advanced Settings" or something like that.

1

try this flutter run --release --no-shrink

2
  • Could not find an option named "no-shrink". Sep 3, 2021 at 8:11
  • try this in terminal
    – Ahmed Raza
    Sep 30, 2021 at 12:20
0

Check if you have given correct permission to the app in AndroidManifest.xml, in my case I simply fixed this issue by giving camera permission

<uses-permission android:name="android.permission.CAMERA" />

before the tag

-1

In my case, after two day of confusion because app crashes only in release mode without any error on console, and errors shown in adb logcat not clear (unknown errors), after that I switching Flutter channel from stable to master, after run release on master channel errors started shown as clear messages, I solved these errors then crashes problem solved.

So my steps is:

1- Switching Flutter channel to master by run this command in terminal:

flutter channel master

2- Run upgrade command in terminal:

flutter upgrade

3- Run app as release:

flutter run --release

4- Watch console to see errors...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.