Skip to content

Release build crashes for both iOS and Android with native libs/FFI #47454

@vaind

Description

@vaind

Steps to Reproduce

I'm working on a plugin using a native library. A debug builds work fine (in the simulator and on device) but when trying to do a release, either using flutter build appbundle (when on a Linux system) or flutter build ios (on Mac), the tool crashes

  1. clone https://github.com/objectbox/objectbox-dart
  2. get the shared library for iOS, manual right now due to another issue Plugin iOS podspec not working with http source #45778
     cd objectbox-dart
     ios/download-framework.sh
    
  3.  cd example/flutter/objectbox_demo
     flutter pub get
     flutter pub run build_runner build
    
  4. flutter run works fine
  5. flutter build appbundle or flutter build ios crashes

Interestingly, the problem only seems to be with 32-bit builds because
flutter build appbundle --target-platform android-arm64,android-x64 works fine. However, 32-bit debug build works in the simulator 🤷‍♂️

iOS build logs

Xcode build done.                                           22.3s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    Building AOT snapshot in release mode (ios-release)...          


    ===== CRASH =====

    si_signo=Segmentation fault: 11(11), si_code=1, si_addr=0x48

    Dart snapshot generator failed with exit code -6

    Building App.framework for arm64...
    Building AOT snapshot in release mode (ios-release)...             15.8s
    Built to build/aot/.
    Snapshotting (DarwinArch.armv7) exited with non-zero exit code: -6
    Snapshotting (DarwinArch.arm64) exited with non-zero exit code: 0
    cp: build/aot/App.framework: No such file or directory
    error: cannot parse the debug map for 'build/aot/App.framework/App': No such file or directory
    Failed to generate debug symbols (dSYM) file for build/aot/App.framework/App.
    note: Using new build system
    note: Planning build
    note: Constructing build description
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14.6 18G1012, locale en-GB)
    • Flutter version 1.12.13+hotfix.5 at /Users/objectbox/flutter
    • Framework revision 27321ebbad (9 days ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.


[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.2.1, Build version 11B500
    • CocoaPods version 1.8.4

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • C4873BC5-FCE8-462E-A780-B66F1C70F96D • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-2 (simulator)


Android build logs

flutter build appbundle
                                                                        
===== CRASH =====                                                       
si_signo=Segmentation fault(11), si_code=1, si_addr=0x48                
Dart snapshot generator failed with exit code -6                        
Target android_aot_release_android-arm failed: Exception: AOT snapshotter exited with code -6
build failed.                                                           
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Script '/home/ivan/lib/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 780
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:compileFlutterBuildRelease'.            
> Process 'command '/home/ivan/lib/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 17s                                                     
Running Gradle task 'bundleRelease'...                                  
Running Gradle task 'bundleRelease'... Done                        17.6s
Gradle task bundleRelease failed with exit code 1

android-verbose.log

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_US.UTF-8)
    • Flutter version 1.12.13+hotfix.5 at /home/ivan/lib/flutter
    • Framework revision 27321ebbad (9 days ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /home/ivan/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /home/ivan/lib/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

! Doctor found issues in 2 categories.

Any ideas would be appreciated.

Metadata

Metadata

Assignees

Labels

c: crashStack traces logged to the consoledependency: dartDart team may need to help usframeworkflutter/packages/flutter repository. See also f: labels.platform-androidAndroid applications specificallyplatform-iosiOS applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions