我需要在我的应用中实现一个插件。为此,我需要迁移到Android embedding v2。通过文档,我尝试了升级。下面是我引用的文档:
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
为了升级,我在MainActivity.kt中更改了导入
设置为import io.flutter.embedding.android.FlutterActivity并删除了onCreate方法。
在AndroidManifest.xml中,我添加了以下元数据
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<meta-data android:name="flutterEmbedding" android:value="2"/>
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />在添加了这个之后,我得到了一些错误,所以我将Application.java更改为
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
@Override
public void registerWith(PluginRegistry registry) {
//GeneratedPluginRegistrant.registerWith(registry);
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
}正在安装应用程序,但在安装后出现以下错误
Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)我试着卸载并重新安装这个应用程序。我也尝试过flutter clean和flutter pub cache repair,但都不起作用。
发布于 2020-11-28 04:18:30
如果你得到了这个错误,MissingPluginException,别忘了你的AndroidManifest中的最后一个bit:
</activity>
</application>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</manifest>https://stackoverflow.com/questions/63896706
复制相似问题