2

MainActivity.java尝试在文件中注册插件时出现此错误

错误日志

    : error: cannot find symbol
  public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
                                              ^

MainActivity.java

package com.orsac.bluis;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {   @Override   public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine);   }

}

AndroidManifest.xml文件中,在android:name=".UniappApplication"android:name=".MainActivity"

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.orsac.bluis">

<application
    android:name=".UniappApplication" // Here
    android:label="BLUIS"
    android:usesCleartextTraffic="true"
    android:networkSecurityConfig="@xml/network_security_config"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity" // Here
        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">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <action android:name="FLUTTER_NOTIFICATION_CLICK" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

我尝试过的事情

Flutter clean
Flutter run
Invalidate caches and restart
4

1 回答 1

1

你应该导入 androidx.annotation.NonNull;

import androidx.annotation.NonNull;
于 2020-10-05T23:42:24.043 回答