Md Shahnawaz
Md Shahnawaz

Reputation: 584

cannot find symbol public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine)

I am getting this error while trying to register plugin in MainActivity.java file

Error log

    : 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);   }

}

In AndroidManifest.xml file, getting Unresolved class error in android:name=".UniappApplication" and 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>

Things I Tried

Flutter clean
Flutter run
Invalidate caches and restart

Upvotes: 3

Views: 2486

Answers (2)

Abdullah Razzaq
Abdullah Razzaq

Reputation: 119

1- Update targetSdkVersion and compileSdkVersion to the latest and equal version in build.gradle(app level) under android section

2- Import these libraries in MainActivity

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin;

Upvotes: 1

Anas Naguib
Anas Naguib

Reputation: 1116

You should import androidx.annotation.NonNull;

import androidx.annotation.NonNull;

Upvotes: 3

Related Questions