juliuscanute / qr_code_scanner

QR Code Scanner for Flutter
BSD 2-Clause "Simplified" License
1.01k stars 785 forks source link

[BUG] [FLUTTER 1.25 & 1.26] Crash when building QRView #186

Closed bdevay closed 3 years ago

bdevay commented 3 years ago

Describe the bug Simply copied your example into my project and tried to navigate to the barcode scanner widget. It reaches the

@override
  Widget build(BuildContext context){}

but crashes in

Widget _buildQrView(BuildContext context) {}

when it tries to build the QRView.

Flutter information [√] Flutter (Channel dev, 1.26.0-1.0.pre, on Microsoft Windows [Version 10.0.19042.685], locale en-US) • Flutter version 1.26.0-1.0.pre at C:\Flutter\SDK\flutter • Framework revision 63062a6443 (6 days ago), 2020-12-13 23:19:13 +0800 • Engine revision 4797b06652 • Dart version 2.12.0 (build 2.12.0-141.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Android\Sdk • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = C:\Android\Sdk • ANDROID_SDK_ROOT = C:\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted.

[√] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (1 available) • motorola one action (mobile) • 10.0.0.7:5555 • android-arm64 • Android 10 (API 29)

• No issues found! Process finished with exit code 0

Device (please complete the following information):

Screenshots It's a crash, no screenshot available

Additional context Stack trace:

java.lang.AbstractMethodError: abstract method "void io.flutter.plugin.platform.PlatformView.onFlutterViewAttached(android.view.View)"
    at io.flutter.plugin.platform.VirtualDisplayController.onFlutterViewAttached(VirtualDisplayController.java:181)
    at io.flutter.plugin.platform.PlatformViewsController$1.createVirtualDisplayForPlatformView(PlatformViewsController.java:233)
    at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:104)
    at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:59)
    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:738)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:343)
    at android.os.Looper.loop(Looper.java:188)
    at android.app.ActivityThread.main(ActivityThread.java:7617)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
juliansteenbakker commented 3 years ago

This is an issue with Flutter beta & dev branch (1.25 & 1.26). There is a workaround by adding android.enableDexingArtifactTransform=false to your gradle.properties file. The issue is being tracked here.