flutter和Android混編下出現“No implementation found for method xxxx on channel”錯誤
flutter和Android混編下出現“No implementation found for method xxxx on channel”錯誤
這個錯誤出現的原因是Plugin的方法沒有找到,也可能是Plugin本身就沒有註冊成功。
在混編情況下出現這個問題,很大概率是我們在網上查詢的資料中是這樣寫的。
import android.os.Bundle
import io.flutter.app.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
private val flutterMethodChannelName = "flutterCallbackMethodChannel"
var methodChannel_callFlutter: MethodChannel? = null
@SuppressLint("NewApi")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(FlutterEngine(this@MainActivity))
methodChannel_callFlutter = MethodChannel(flutterView, flutterMethodChannelName)
}
}
這個程式碼在flutter更新了FlutterActivity後就會導致這個問題,不能再引用io.flutter.app.FlutterActivity這個FlutterActivity,而應該改用io.flutter.embedding.android.FlutterActivity。同時,繼承自新版本FlutterActivity的MainActivity找不到flutterView這個方法,因此要改用getFlutterEngine().getDartExecutor().getBinaryMessenger()來代替。
程式碼改為:
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
private val flutterMethodChannelName = "flutterCallbackMethodChannel"
var methodChannel_callFlutter: MethodChannel? = null
@SuppressLint("NewApi")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
methodChannel_callFlutter = MethodChannel(flutterEngine!!.dartExecutor.binaryMessenger, flutterMethodChannelName)
}
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
參考文章
https://blog.csdn.net/qq_40928212/article/details/105545875
https://blog.csdn.net/oZhuiMeng123/article/details/98120505
https://blog.csdn.net/weixin_44160584/article/details/108244793
相關文章
- 如何處理SAP CRM Web Service錯誤 - Virtual Interface Method XXXX not supportedWeb
- Flutter 安裝搭建報錯 Android sdkmanager tool not foundFlutterAndroid
- 使用@Service註解出現No bean named 'xxxx' available]錯誤BeanAI
- react元件內報implementation()方法錯誤!React元件
- Nginx下出現 see security.limit_extensions錯誤的解決方法NginxMIT
- PostgreSQL cache lookup failed for type XXXX 錯誤SQLAI
- 今天在object-c 和swift 混編的時候出現錯誤:could not build module foundationObjectSwiftUI
- PyTorch出現錯誤“RuntimeError: Found dtype Double but expected Float”PyTorchError
- Flutter之異常和錯誤Flutter
- win10系統下出現藍屏錯誤nvlddmkm.sys如何解決Win10
- 深入小程式系列之二、Flutter 和小程式混編Flutter
- 小程式錯誤:Component is not found in path
- Flutter 最常出現的典型錯誤Flutter
- [混編] iOS原生專案- 接入FlutteriOSFlutter
- 記一次android app啟動錯誤 Error running :Default Activity not foundAndroidAPPError
- flutter庫【path_provider】編譯錯誤指導FlutterIDE編譯
- android 打包出現錯誤Error: ResourceNameAndroidError
- OC和Swift混編Swift
- Angular 內容投影出現 No provider for TemplateRef found 錯誤的單步除錯AngularIDE除錯
- win10系統下出現藍色畫面錯誤nvlddmkm.sys如何解決Win10
- IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokensExceptionHTTP
- iOS Native混編Flutter互動實踐iOSFlutter
- Flutter外掛開發指南01: 通道Channel的編寫與實現Flutter
- android 原生混編 flutter 並使用 flutter_boost進行跳轉的步驟以及注意事項AndroidFlutter
- Eclipse 啟動專案錯誤:class not foundEclipse
- Flutter 2.2.X 版本熱修復實現思路分享(Android+Flutter混開專案)FlutterAndroid
- 報錯xxxx of undefinedUndefined
- Android編譯通過,執行編譯錯誤問題總結Android編譯
- NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load xxxx錯誤解決方法ErrorAIXMLHTTP
- 出現錯誤 Project ‘org.springframework.boot:spring-boot-starter-parent’ not foundProjectSpringFrameworkboot
- shell指令碼執行錯誤 $‘\r‘:command not found指令碼
- 解決shell指令碼錯誤$’r’ command not found指令碼
- 解決 The ‘supervisor==3.2.0‘ distribution was not found and is required by the application錯誤UIAPP
- Qt處理中文編碼出現錯誤QT
- Centos7系統建立使用者時出現“useradd: user ‘xxxx‘ already exists”錯誤CentOS
- OC和Swift混編經驗Swift
- Objective-C和Swift混編ObjectSwift
- iOS UMeng OC和Swift混編iOSSwift