0

我正在尝试在我的 android flutter 应用程序中实现 Instabug(崩溃分析)。

我尝试从https://pub.dev/packages/instabug_flutter安装,但我不确定应该将新的 CustomFlutterApplication 类放在哪里。

这是我的代码

package io.flutter.plugins;

import java.util.ArrayList;


public class CustomFlutterApplication extends FlutterApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        ArrayList<String> invocation_events = new ArrayList<>();
        invocation_events.add(InstabugFlutterPlugin.INVOCATION_EVENT_FLOATING_BUTTON);
        InstabugFlutterPlugin instabug = new InstabugFlutterPlugin();
        instabug.start(CustomFlutterApplication.this, "2d355f559ea67051a56fce82603f8e41", invocation_events);
        instabug.setWelcomeMessageMode("WelcomeMessageMode.disabled");
    }
}

路径:app/src/main/java/io/flutter/plugins/CustomFlutterApplication.java

我还重命名了 androidManifest.xml 文件中的android:name代码行

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ju.test_app_v2">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name=".CustomFlutterApplication"
        android:label="test_app_v2"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">

路径:app/src/main/AndroidManifest.xml

这是我得到的主要错误,我想我可能必须导入其他东西才能识别 FlutterApplication?我不确定

/Users/juliaju/AndroidStudioProjects/test_app_v2/android/app/src/main/java/io/flutter/plugins/CustomFlutterApplication.java:6: error: cannot find symbol
public class CustomFlutterApplication extends FlutterApplication {
                                              ^
  symbol: class FlutterApplication
/Users/juliaju/AndroidStudioProjects/test_app_v2/android/app/src/main/java/io/flutter/plugins/CustomFlutterApplication.java:7: error: method does not override or implement a method from a supertype
    @Override
4

1 回答 1

0

尝试导入 InstabugFlutterPlugin:

import com.instabug.instabugflutter.InstabugFlutterPlugin;

查看 Flutter文档以获取更多详细信息

于 2021-08-16T10:28:22.940 回答