flutterkotlindartlocalauthentication

PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity., null) in flutter


I am trying add Figureprint authentication using local_auth package of flutter i used same example given that package here it is. And i am getting this error

I/flutter (27676): PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity., null)

I have try this solution But the problem is that I don't know about kotlin.

Here is my Mainactivity.kt

package com.example.bio_met

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

Solution

  • I Found the answer and it worked for me. Here it is just replace your code with following code in MainActivity.kt file.

    package //your package name for eg.com.example.filename
    
    import androidx.annotation.NonNull;
    import io.flutter.embedding.android.FlutterActivity
    import io.flutter.embedding.android.FlutterFragmentActivity
    import io.flutter.embedding.engine.FlutterEngine
    import io.flutter.plugins.GeneratedPluginRegistrant
    
    class MainActivity: FlutterFragmentActivity() {
        override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine){
            GeneratedPluginRegistrant.registerWith(flutterEngine);
        }
    }