我刚刚从颤振中复制了代码。dev并对其进行了修改,出现以下错误
E/flatter(2639):[ERROR:flatter/lib/ui/ui\u dart\u state.cc(177)]未处理的异常:MissingPluginException(在通道My channel上找不到方法myNativeFunction的实现)*我想将一条消息从本机java代码打印到Flatter ui*
This is my Main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static const platform = const MethodChannel('My Channel');
String message = "No Message from Native App";
Future<void> callNative() async {
String messageFromNative = "No message from Native";
try {
messageFromNative = await platform.invokeMethod('myNativeFunction');
print(messageFromNative);
} on PlatformException catch (e) {
print("error + '${e.message}' ");
message = "Failed to get Native App function: '${e.message}'.";
}
setState(() {
message = messageFromNative;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Native Demo'),
),
body: Center(
child: Column(
children: [
Text(message),
RaisedButton(child: Text('Native '), onPressed: callNative)
],
),
),
),
);
}
}
This is my MainActivity.java
package com.example.batterylevel;
import android.util.Log;
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.MethodChannel;
public class MainActivity extends FlutterActivity {
public static final String CHANNEL="MyChannel";
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
.setMethodCallHandler(
(call, result) -> {
if(call.method.equals("myNativeFunction"))
{
String messageToFlutter=myNativeFunction();
result.success(messageToFlutter);
}else {
result.notImplemented();
Log.d("RD","else");
}
}
);
}
String myNativeFunction()
{
return "Message from Android";
}
}
在Main Active
中,方法通道名称应与省道中定义的方法通道名称匹配。
飞镖
static const platform = const MethodChannel('My Channel');
JAVA
public static final String CHANNEL = "My Channel"; // on dart side it's "My Channel", but you've written "MyChannel"
未处理的异常:MissingPluginException(在channel Flatter_inapp上找不到方法initConnection的实现)。当我在android上使用Flatter in-app purchase插件时,会出现MissingPluginException异常。在iOS上,它运行得很好 当我运行或调试应用程序时,会出现以下错误:
我正在尝试构建Android应用程序,但收到一个错误MissingPluginException(在channel testfairy上找不到方法log的实现): TestFairy插件的当前版本:TestFairy:^2.0。1颤振(通道稳定,1.22.2)Dart版本2.10。2.此外,我还添加了: 我使用命令运行应用程序。 如何解决此错误?
E/flatter(13237):[错误:flatter/lib/ui/ui\u dart\u state.cc(177)]未处理的异常:MissingPluginException(在lyokone/location通道上找不到getLocation方法的实现) 我正在使用位置和地点选择器插件 未处理的异常:平台异常(错误,java.lang.非法状态异常:试图创建未注册类型的平台视图:plug
有人能解决这个问题吗? E/flutter(6629):尝试呼叫: createUserSusEmailAndPassword(email:"nehalt88@gmail.com",密码:"123456")E/flutter(6629):#0Object.noSuchMethod(飞镖: core-patch/object_patch.dart:63: 5)E/flutter(6629):#1Re
我在这里得到这个错误。并且,试图解决它。 > E/flatter(14838):[错误:flatter/lib/ui/ui_dart_state.cc(177)]未处理的异常:缺少PluginException(在通道插件上找不到方法getApplicationDocumentsDirectory.flatter.io/path_provider的实现)E/flatter(14838):\0 Ge
我正在做一个项目,在与我的队友合并代码之前,package sms_autofill运行正常,但在代码合并后,我已经运行了Flatter clean,但它仍然显示两个错误,如下所示: 和 我的代码: 颤振博士-v: pubspec。亚马尔: 我不知道它有什么问题,我已经尝试在互联网上搜索,似乎没有与之相关的解决方案。