Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local_auth: ^0.6.0+1 works fail #45230

Closed
suchul opened this issue Nov 20, 2019 · 20 comments
Closed

local_auth: ^0.6.0+1 works fail #45230

suchul opened this issue Nov 20, 2019 · 20 comments
Labels
p: local_auth Plugin for local authentification package flutter/packages repository. See also p: labels. waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@suchul
Copy link

suchul commented Nov 20, 2019

It works well in older versions(0.4.1) but it doesn't work in newer versions

 bool isAuthorized = false;
      try {
        isAuthorized = await _localAuthentication.authenticateWithBiometrics(
          localizedReason: "test",
          useErrorDialogs: true,
          stickyAuth: true,
        );
      } on PlatformException catch (e) {
        print(e);
      }

print(e);
PlatformException(no_fragment_activity, local_auth plugin requires activity to be a FragmentActivity., null)

Please check this issue

@iapicca
Copy link
Contributor

iapicca commented Nov 20, 2019

Hi @suchul
could you please provide your flutter doctor -v
and your flutter run --verbose?
Also, to better address the issue, would be helpful
if you could post a minimal code sample to reproduce the problem
Thank you

@iapicca iapicca added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 20, 2019
@suchul
Copy link
Author

suchul commented Nov 21, 2019 via email

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 21, 2019
@iapicca iapicca added p: first party p: local_auth Plugin for local authentification c: regression It was better in the past than it is now labels Nov 21, 2019
@suchul
Copy link
Author

suchul commented Nov 25, 2019

It works well in older versions(0.4.1) but it doesn't work in newer versions

pubspec.yml ==> local_auth: ^0.6.0+1

if you run this app, you can see the problem

And
pubspec.yml ==> local_auth: ^0.4.0+1.

if you modify the code and run it, it works fine.

this app was created as a flutter application

Please check you this issue

Thanks
sckang

test_local_auth.zip
https://drive.google.com/file/d/1VLvcwQXfxKTQuShV_jWxVjCx9Oy-vt3J/view?usp=drive_web

@viztushar
Copy link

base on the error you have to change your MainActivity

public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }
}

to

public class MainActivity extends FlutterFragmentActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }
}

@iapicca
Copy link
Contributor

iapicca commented Dec 12, 2019

Hi @suchul
are you still experiencing this issue with the latest version of Flutter?
thank you

@iapicca iapicca added waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds and removed c: regression It was better in the past than it is now labels Dec 12, 2019
@VladyslavBondarenko
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.
Could everyone who still has this problem please file a new issue with the exact descriptions what happens, logs and the output of 'flutter doctor -v' please.
All system setups can be slightly different so its always better to open new issues and reference related issues.

@siva563
Copy link

siva563 commented Jan 23, 2020

@suchul did you got any solution for this issue. I am facing same issue. could you please let me know if you fixed.

@VladyslavBondarenko I am facing same issue.

@suchul
Copy link
Author

suchul commented Jan 23, 2020 via email

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 23, 2020
@no-response no-response bot reopened this Jan 23, 2020
@siva563
Copy link

siva563 commented Jan 24, 2020

@suchul

I changed As you suggested. but I am getting below Error:

app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:8:27: error: expecting a top level declaration
public class MainActivity extends FlutterFragmentActivity {
                          ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:8:35: error: expecting a top level declaration          
public class MainActivity extends FlutterFragmentActivity {
                                  ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:8:59: error: expecting a top level declaration     
public class MainActivity extends FlutterFragmentActivity {
                                                          ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:8:59: error: function declaration must have a name
public class MainActivity extends FlutterFragmentActivity {
                                                          ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:10:52: error: expecting an element
  protected void onCreate(Bundle savedInstanceState) {
                                                   ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:9:4: error: unresolved reference: override
  @override
   ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:10:3: error: unresolved reference: protected       
  protected void onCreate(Bundle savedInstanceState) {
  ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:10:18: error: unresolved reference: onCreate
  protected void onCreate(Bundle savedInstanceState) {
                 ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:10:27: error: unresolved reference: Bundle
  protected void onCreate(Bundle savedInstanceState) {
                          ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:11:5: error: no supertypes are accessible in this context
    super.onCreate(savedInstanceState);
    ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:11:20: error: unresolved reference: savedInstanceState  
    super.onCreate(savedInstanceState);
                   ^
app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt:12:44: error: 'this' is not defined in this context     
    GeneratedPluginRegistrant.registerWith(this);
                                           ^

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with
    --scan to get full insights.

  • Get more help at https://help.gradle.org

@VladyslavBondarenko Any help from your side. could you please look inti it once.

@siva563
Copy link

siva563 commented Jan 24, 2020

@dnfield Could you please look into it above issue.

@VladyslavBondarenko
Copy link

@suchul
Mentioned code - java-code, wasn't you proposed to convert it to kotlin?

This main file in kotlin should look like:

package com.example.yourpackagename

import android.os.Bundle

import io.flutter.app.FlutterFragmentActivity
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterFragmentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        GeneratedPluginRegistrant.registerWith(this)
    }
}

@siva563
Copy link

siva563 commented Jan 24, 2020

@VladyslavBondarenko where should add this code I mean Which file? I am not able to find any MainActivity.Java file

@VladyslavBondarenko
Copy link

@suchul
In your app\src\main\kotlin\com\example\ntta_mobile_app\MainActivity.kt

@VladyslavBondarenko
Copy link

@suchul
Also if you have Type mismatch: required PluginRegistry, Found: MainActivity on registerWith(this), try firebase/flutterfire#1684 (comment)

@dnfield
Copy link
Contributor

dnfield commented Jan 24, 2020

I think @mklim @matthew-carroll or @blasten would know what's going on better here

@matthew-carroll
Copy link
Contributor

I've read through this read but it's not clear to me if a problem still exists, and if it does, what the particular problem is. There was a recommendation to change from FlutterActivity to FlutterFragmentActivity. Did that solve the original problem in this issue? Most of the comments after that appear to be confusion around Java vs Kotlin implementations...

@matthew-carroll matthew-carroll added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 24, 2020
@just1random
Copy link

just1random commented Jan 25, 2020

I just created a new project using -a java flag (cause I don't want kotlin).
Here's the default MainActivity.java:

package com.example.tired;

import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;

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

I can't make this work by importing import io.flutter.app.FlutterFragmentActivity And changing FlutterActivity to FlutterFragmentActivity. In total i can't make this work with a brand new project. Example repo has a different MainActivity.java and it does'nt work. Here's example repo MainActivity.java:

package io.flutter.plugins.localauthexample;

import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.localauth.LocalAuthPlugin;

public class MainActivity extends FlutterFragmentActivity {
  // TODO(bparrishMines): Remove this once v2 of GeneratedPluginRegistrant rolls to stable. https://github.com/flutter/flutter/issues/42694
  @Override
  public void configureFlutterEngine(FlutterEngine flutterEngine) {
    flutterEngine.getPlugins().add(new LocalAuthPlugin());
  }
}

Edit: Got it working by the following MainActivity.java:

import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;

import android.os.Build;
import android.view.ViewTreeObserver;
import android.view.WindowManager;

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

@Theo6890
Copy link

Theo6890 commented Feb 10, 2020

Edit: Got it working by the following MainActivity.java:

import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;

import android.os.Build;
import android.view.ViewTreeObserver;
import android.view.WindowManager;

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

Same for Kotlin :

import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.engine.FlutterEngine;

import io.flutter.plugins.GeneratedPluginRegistrant

import android.os.Build;
import android.view.ViewTreeObserver;
import android.view.WindowManager;

class MainActivity : FlutterFragmentActivity() {
   override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
       GeneratedPluginRegistrant.registerWith(flutterEngine)
   }
} 

@iapicca
Copy link
Contributor

iapicca commented Mar 20, 2020

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

Could everyone who still has this problem please file a new issue with the exact descriptions what happens, logs and the output of 'flutter doctor -v' please.
All system setups can be slightly different so it's always better to open new issues and reference related issues.

@iapicca iapicca closed this as completed Mar 20, 2020
@lock
Copy link

lock bot commented Apr 4, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators Apr 4, 2020
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p: local_auth Plugin for local authentification package flutter/packages repository. See also p: labels. waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

9 participants