Duplicate plugin error when restarting on iOS 13

See original GitHub issue

This problem seems still present in 1.3.3 when hot restarting flutter application

2019-11-18 09:17:04.554735+0100 Runner[94428:1701158] startBackgroundIsolate
2019-11-18 09:17:04.554872+0100 Runner[94428:1701158] *** Assertion failure in -[FlutterEngine registrarForPlugin:], ../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm:580.
2019-11-18 09:17:04.579922+0100 Runner[94428:1701158] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Duplicate plugin key: vn.hunghd.flutter_downloader'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff23c4f02e __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x00007fff50b97b20 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff23c4eda8 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff256c9b61 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   Flutter                             0x00000001088aacc9 -[FlutterEngine registrarForPlugin:] + 282
	5   Runner                              0x0000000104fb8dfe $s6Runner15registerPlugins33_A9240C085443F9A3748492E4015AD82ALL8registryySo21FlutterPluginRegistry_p_tF + 126
	6   Runner                              0x0000000104fb8c2e $s6Runner15registerPlugins33_A9240C085443F9A3748492E4015AD82ALL8registryySo21FlutterPluginRegistry_p_tFTo + 30
	7   flutter_downloader                  0x000000010aaa8687 -[FlutterDownloaderPlugin startBackgroundIsolate:] + 823
	8   flutter_downloader                  0x000000010aaae38b -[FlutterDownloaderPlugin initializeMethodCall:result:] + 187
	9   flutter_downloader                  0x000000010aab21f0 -[FlutterDownloaderPlugin handleMethodCall:result:] + 256
	10  Flutter                             0x000000010892a4fd __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
	11  Flutter                             0x00000001088c3ec0 _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 166
	12  Flutter                             0x00000001088c7780 _ZN7flutter15PlatformViewIOS21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 38
	13  Flutter                             0x0000000108924db3 _ZNSt3__110__function6__funcIZN7flutter5Shell29OnEngineHandlePlatformMessageEN3fml6RefPtrINS2_15PlatformMessageEEEE4$_31NS_9allocatorIS8_EEFvvEEclEv + 57
	14  Flutter                             0x00000001088d63f1 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 123
	15  Flutter                             0x00000001088db742 _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26
	16  CoreFoundation                      0x00007fff23bb2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
	17  CoreFoundation                      0x00007fff23bb2632 __CFRunLoopDoTimer + 1026
	18  CoreFoundation                      0x00007fff23bb1c8a __CFRunLoopDoTimers + 266
	19  CoreFoundation                      0x00007fff23bac9fe __CFRunLoopRun + 2238
	20  CoreFoundation                      0x00007fff23babe16 CFRunLoopRunSpecific + 438
	21  GraphicsServices                    0x00007fff38438bb0 GSEventRunModal + 65
	22  UIKitCore                           0x00007fff4784fb48 UIApplicationMain + 1621
	23  Runner                              0x0000000104fb90a8 main + 72
	24  libdyld.dylib                       0x00007fff51a1dc25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Appdelegate.swift

import UIKit
import Flutter
import Firebase
import flutter_downloader

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

private func registerPlugins(registry: FlutterPluginRegistry) {
    //
    // Integration note:
    //
    // In Flutter, in order to work in background isolate, plugins need to register with
    // a special instance of `FlutterEngine` that serves for background execution only.
    // Hence, all (and only) plugins that require background execution feature need to
    // call `register` in this function.
    //
    // The default `GeneratedPluginRegistrant` will call `register` of all plugins integrated
    // in your application. Hence, if you are using `FlutterDownloaderPlugin` along with other
    // plugins that need UI manipulation, you should register `FlutterDownloaderPlugin` and any
    // 'background' plugins explicitly like this:
    //
    FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "vn.hunghd.flutter_downloader"))
    //
    // GeneratedPluginRegistrant.register(with: registry)
}

_Originally posted by @PatStadler in https://github.com/fluttercommunity/flutter_downloader/issues/154#issuecomment-554907653_

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Gicminoscommented, Nov 19, 2019

I am having the same problem without hotrestarting, even only installing.

0reactions
bartekpaciacommented, May 23, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to set plugin placeholders … | Apple Developer Forums
The app compiles fine, but when the Simulartor starts, it throws out the below error: "Failed to set plugin placeholders for com.xxxxxxxxxx.xxxxxxxx.
Read more >
Thread 1: "Duplicate plugin key: InAppWebViewFlutterPlugin"
I am getting "Duplicate plugin key: InAppWebViewFlutterPlugin" error on AppDelegate . However, I can't spot where to fix?
Read more >
iPhone 13 Black Screen, 3 Easy Ways to Fix it 2022 (No Data ...
Recently my iPhone 13 suddenly black screen, but I find a few ways that can fix it, if you don't know how to...
Read more >
iOS 13 or iPadOS problems and how to fix them - AppleToolBox
If you find yourself in this situation, the best thing to do is Force Restart your iPhone, iPad, or iPod touch. Then try...
Read more >
Customer Support - Plugin Alliance
Do your plugins work on iOS or will you ever make your amps available for ... I downloaded an installer and I got...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found