Moor: Does not build in Release Mode: ../../third_party/dart/runtime/vm/compiler/backend/il.h: 999: error: unreachable code

Created on 19 May 2020  Â·  17Comments  Â·  Source: simolus3/moor

Hi,

I'm having an issue after upgrading to moor_ffi 0.6.0 on the current stable version of flutter.
I cannot build my app in release mode. Debug mode works fine. I also happens on a very basic project and can be reproduced in the integrations tests of moor.

To reproduce, navigate to:
moor/extras/integration_tests/flutter_db
And try to build the app in release mode:

flutter build apk --release -t lib/moor_ffi.dart
! moor 3.1.0 from path ../../../moor
! moor_flutter 3.0.0 from path ../../../moor_flutter
Running "flutter pub get" in flutter_db...                          0.6s
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
[!] Your app isn't using AndroidX.
    To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.
../../third_party/dart/runtime/vm/compiler/backend/il.h: 999: error: unreachable code
Dart snapshot generator failed with exit code -6
../../third_party/dart/runtime/vm/compiler/backend/il.h: 999: error: unreachable code
Dart snapshot generator failed with exit code -6
Target android_aot_release_android-arm64 failed: Exception: AOT snapshotter exited with code -6
Target android_aot_release_android-x64 failed: Exception: AOT snapshotter exited with code -6
build failed.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/kami/development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 882

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/kami/development/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                      24.8s
Gradle task assembleRelease failed with exit code 1

The iOS build fails with a similar error.

flutter doctor:

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.4 19E287, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.6)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1.2)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.45.0)
[✓] Connected device (1 available)

I also tried it in the current flutter beta version, same error.

I'm not quite sure if that's really an issue with moor or a bug in the build system - Do you have any clues why this might happen? If not, I'll open an issue in the flutter project.

Most helpful comment

I requested it in https://github.com/flutter/flutter/issues/58631 . If this gets enough thumbs up, maybe they'll hotfix it.

All 17 comments

I can reproduce this by running dart2native test/vm_test.dart, so it's not a Flutter bug. It's definitely a bug in Dart though, I'll try to come up with a smaller repro.

I tried to poke around a bit, but I couldn't find a much smaller repro. Interestingly, aot-compiling some test files inside moor_ffi doesn't fail, only the whole integration test. https://github.com/dart-lang/sdk/issues/41971

Confirm the issue.

I am running into this as well, 2 apps don't build any more so I have to stay on 3.0.0 for now.

Same here, actually solved by downgrading to moor_ffi: "0.5.0".

I was scratching my head for a while with this one too. moor_ffi 0.5.0 still works.

Had this issue for 2 days and finally realised it's because of moor_ffi 0.6.0... After downgrading to 0.5.0 everything works fine.

Same issue, fixed by downgrading moor_ffi to 0.5.0

Same issue here, fixed by downgrading moor_ffi to 0.5.0

This is now fixed on the flutter master branch

Hopefully they pick this into stable.

I requested it in https://github.com/flutter/flutter/issues/58631 . If this gets enough thumbs up, maybe they'll hotfix it.

This is now fixed on flutter beta branch, only one more branch to go.

If I'm also having https://github.com/simolus3/moor/issues/420, the only solution is to use beta, correct?

@szotp Yes

Steps to fix it as of today with latest update on Jul 29, 2020:

  1. Update Moor Package to v3.3.0
  2. Update Moor_Generator to v3.3.0
  3. Install 'sqlite3_flutter_libs' package (as updated in the docs)
  4. Remove moor_ffi package as it is deprecated now.
  5. Change imports from moor_ffi to package:moor/ffi.dart.
  6. Check installed versions for path, path_provider and build_runner using flutter pub outdated

Clear build cache and build runner cache.
Build production app now without any errors.

Dart 2.9 and Flutter 1.20 contain the fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jerryzhoujw picture jerryzhoujw  Â·  4Comments

cadaniel picture cadaniel  Â·  4Comments

omidraha picture omidraha  Â·  3Comments

simolus3 picture simolus3  Â·  4Comments

tony123S picture tony123S  Â·  4Comments