GeneratedPluginRegistrant不能应用-Flutter

问题描述 投票:1回答:1

当我构建Flutter应用程序时,此错误显示:

错误:不兼容的类型:MainActivity无法转换为FlutterEngine GeneratedPluginRegistrant.registerWith(this);

我去上课的github,看到了区别:https://github.com/theyakka/fluro/blob/master/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java

如果将其放在项目中,则在构建应用程序时,我的班级会为此自动更改:

package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.FlutterEngine;

/**
 * Generated file. Do not edit.
 * This file is generated by the Flutter tool based on the
 * plugins that support the Android platform.
 */
@Keep
public final class GeneratedPluginRegistrant {
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
  }
}

我遵循本教程:https://www.youtube.com/watch?v=NXuAzXY_KOo

我需要在后台运行我的应用程序以获取当前位置,但不起作用。

android flutter background-service
1个回答
0
投票

您需要导入插件,

import io.flutter.plugin.common.PluginRegistry;

并通过FlutterActivity扩展您的课程。

© www.soinside.com 2019 - 2024. All rights reserved.