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
相關文章
- react元件內報implementation()方法錯誤!React元件
- Flutter 安裝搭建報錯 Android sdkmanager tool not foundFlutterAndroid
- 如何處理SAP CRM Web Service錯誤 - Virtual Interface Method XXXX not supportedWeb
- Nginx下出現 see security.limit_extensions錯誤的解決方法NginxMIT
- DBCA建庫出現CHMOD NOT FOUND錯誤
- 今天在object-c 和swift 混編的時候出現錯誤:could not build module foundationObjectSwiftUI
- 深入小程式系列之二、Flutter 和小程式混編Flutter
- [混編] iOS原生專案- 接入FlutteriOSFlutter
- Flutter之異常和錯誤Flutter
- 呼叫 webapi的put和delete 報"Method Not Allowed" 405 錯誤。WebAPIdelete
- Flutter 最常出現的典型錯誤Flutter
- win10系統下出現藍屏錯誤nvlddmkm.sys如何解決Win10
- OC和Swift混編Swift
- Flutter外掛開發指南01: 通道Channel的編寫與實現Flutter
- iOS Native混編Flutter互動實踐iOSFlutter
- PyTorch出現錯誤“RuntimeError: Found dtype Double but expected Float”PyTorchError
- win10系統下出現藍色畫面錯誤nvlddmkm.sys如何解決Win10
- 小程式錯誤:Component is not found in path
- MyBatis 錯誤:Invalid bound statement (not found)MyBatis
- android 原生混編 flutter 並使用 flutter_boost進行跳轉的步驟以及注意事項AndroidFlutter
- Android Studio 編譯錯誤集錦Android編譯
- 使用@Service註解出現No bean named 'xxxx' available]錯誤BeanAI
- Flutter 2.2.X 版本熱修復實現思路分享(Android+Flutter混開專案)FlutterAndroid
- ORA-600(kkoipt:invalid join method)錯誤
- 安裝 ESXi 出現錯誤 ERROR 1962: No operating system foundError
- Angular 內容投影出現 No provider for TemplateRef found 錯誤的單步除錯AngularIDE除錯
- OC和Swift混編經驗Swift
- iOS UMeng OC和Swift混編iOSSwift
- Objective-C和Swift混編ObjectSwift
- Invalid bound statement (not found)錯誤解決
- ios交叉比編譯android錯誤解決iOS編譯Android
- [混編] iOS原生專案- iOS/flutter 程式碼互動iOSFlutter
- 高德地圖No implementation found for long com.autonavi.amap.mapcore.MapCore地圖
- PostgreSQL cache lookup failed for type XXXX 錯誤SQLAI
- IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokensExceptionHTTP
- Flutter在iOS裝置執行報錯fatal error: 'Flutter/Flutter.h' file not foundFlutteriOSError
- android 打包出現錯誤Error: ResourceNameAndroidError
- 記一次android app啟動錯誤 Error running :Default Activity not foundAndroidAPPError