kalismeras61 / flutter_lock_screen

This package gives you lock screen or pass code page
MIT License
61 stars 25 forks source link

Cannot find symbol: PackageManager.FEATURE_IRIS #3

Closed pratik037 closed 3 years ago

pratik037 commented 5 years ago

I am using _flutter_lock_screen(^1.0.5)_ plugin along with _local_auth(0.6.0)_ in my project. When I am trying to build the project but it keeps returning the same error everytime. I have changed the FlutterActivity to FlutterFragmentActivity as given in the documentation The Fingerprint permission is also added to the AndroidManifest.xml file

Launching lib/main.dart on Redmi Note 5 Pro in debug mode...
/home/pratik037/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/local_auth-0.6.0/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java:104: error: cannot find symbol
          if (packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)) {
                                                            ^
  symbol:   variable FEATURE_FACE
  location: class PackageManager

/home/pratik037/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/local_auth-0.6.0/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java:107: error: cannot find symbol
          if (packageManager.hasSystemFeature(PackageManager.FEATURE_IRIS)) {
                                                            ^
  symbol:   variable FEATURE_IRIS
  location: class PackageManager
2 errors

Here's my code:

import 'package:flutter/material.dart';
import 'package:flutter_lock_screen/flutter_lock_screen.dart';
import 'package:local_auth/local_auth.dart';
import 'package:flutter/services.dart';

class PassCodeScreen extends StatefulWidget {
  PassCodeScreen({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _PassCodeScreenState createState() => new _PassCodeScreenState();
}

class _PassCodeScreenState extends State<PassCodeScreen> {
  bool isFingerprint;

  Future<Null> biometrics() async {
    final LocalAuthentication auth = new LocalAuthentication();
    bool authenticated = false;

    try {
      authenticated = await auth.authenticateWithBiometrics(
          localizedReason: 'Scan your fingerprint to authenticate',
          useErrorDialogs: true,
          stickyAuth: true);
    } on PlatformException catch (e) {
      print(e);
    }
    if (!mounted) return;
    if (authenticated) {
      setState(() {
        isFingerprint = true;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    var myPass = [1, 2, 3, 4];
    return LockScreen(
        title: "This is Screet ",
        passLength: myPass.length,
        bgImage: "images/pass_code_bg.jpg",
        fingerPrintImage: "images/fingerprint.png",
        showFingerPass: true,
        fingerFunction: biometrics,
        fingerVerify: isFingerprint,
        borderColor: Colors.white,
        showWrongPassDialog: true,
        wrongPassContent: "Wrong pass please try again.",
        wrongPassTitle: "Opps!",
        wrongPassCancelButtonText: "Cancel",
        passCodeVerify: (passcode) async {
          for (int i = 0; i < myPass.length; i++) {
            if (passcode[i] != myPass[i]) {
              return false;
            }
          }

          return true;
        },
        onSuccess: () {
          Navigator.pushReplacementNamed(context, '/');
        });
  }
}

Here's flutter doctor -v output:

pratik037@Pratik-Asus:~/Flutter Projects/remindme$ flutter doctor -v
[✓] Flutter (Channel beta, v1.9.1+hotfix.2, on Linux, locale en_GB.UTF-8)
    • Flutter version 1.9.1+hotfix.2 at /home/pratik037/Flutter/flutter
    • Framework revision 2d2a1ffec9 (3 weeks ago), 2019-09-06 18:39:49 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/pratik037/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: /home/pratik037/Android_Studio/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Android Studio (version 3.5)
    • Android Studio at /home/pratik037/Android_Studio/android-studio
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Community Edition (version 2019.1)
    • IntelliJ at /home/pratik037/Downloads/idea-IC-183.5912.21
    • Flutter plugin version 35.2.2
    • Dart plugin version 191.6183.88

[✓] VS Code (version 1.38.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • Redmi Note 5 Pro • 41d6ca4b • android-arm64 • Android 9 (API 28)

• No issues found!

Can you please help me to solve this issue?

ibhavikmakwana commented 5 years ago

Seems like this constants aren't available in the package.

pratik037 commented 5 years ago

Seems like this constants aren't available in the package.

I checked the file and it is there, but it should be invoked only when the API target is greater than 29, which isnt true in my case.

pratik037 commented 5 years ago

@ibhavikmakwana this is the implementation in the package.


PackageManager packageManager = activity.getPackageManager();
        if (Build.VERSION.SDK_INT >= 23) {
          if (packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
            biometrics.add("fingerprint");
          }
        }
        if (Build.VERSION.SDK_INT >= 29) {
          if (packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)) {
            biometrics.add("face");
          }
          if (packageManager.hasSystemFeature(PackageManager.FEATURE_IRIS)) {
            biometrics.add("iris");
          }
        }
        result.success(biometrics);
      } catch (Exception e) {
        result.error("no_biometrics_available", e.getMessage(), null);
      }
    } else {
      result.notImplemented();
    }
pratik037 commented 5 years ago

@kalismeras61 any help?

kalismeras61 commented 5 years ago

Let me check and will write you!

kalismeras61 commented 5 years ago

I update example folder could you run example project with your phone? Please tell me result.

pratik037 commented 5 years ago

I update example folder could you run example project with your phone? Please tell me result.

Sure thing, gimme a while. I'll update here

pratik037 commented 5 years ago

I update example folder could you run example project with your phone? Please tell me result.

Hey I tried your example by cloning it in my local system, got the same error as before along with something more;

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':local_auth:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for 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
BUILD FAILED in 1m 8s
Gradle task assembleDebug failed with exit code 1
kalismeras61 commented 5 years ago

Which sdk version are you using? conpileSdkVersion should be 28

pratik037 commented 5 years ago

Which sdk version are you using? conpileSdkVersion should be 28

Yes compileSDK version is 28. And the recently posted error is from your own example. I cloned your repository and executed the example folder files using VSCode.

kalismeras61 commented 5 years ago

It is interesting i tested it working fine.

pratik037 commented 5 years ago

It is interesting i tested it working fine.

How? I seriously cloned your project into my local system, opened the example folder in VSCode and pressed Ctrl+F5 to start debugging

pratik037 commented 5 years ago

Here's the app level build.gradle file from the example project

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.flutterpasscodeexample"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {

}
kalismeras61 commented 5 years ago

I'am sorry but i test with stable version and also master version of Flutter. I did'nt see any error. Could you run flutter clean and try again?

pratik037 commented 5 years ago

I'am sorry but i test with stable version and also master version of Flutter. I did'nt see any error. Could you run flutter clean and try again?

Sure thing. Also let me know what changes to make so that this plugin becomes useable in my app. I'll update here after running flutter clean.

pratik037 commented 5 years ago

I'am sorry but i test with stable version and also master version of Flutter. I did'nt see any error. Could you run flutter clean and try again?

I switched to master branch too for trying this out but same output. Can you guide me through what to do, honestly I have no idea why its not working.

kalismeras61 commented 5 years ago

I dont know what exactly going on. Be sure your android studio is latest version and your build tools is greater than 27. Upgrade your gradle version.

I saw first comment everything is fine. Did you test it with emulator?

pratik037 commented 5 years ago

I dont know what exactly going on. Be sure your android studio is latest version and your build tools is greater than 27. Upgrade your gradle version.

I saw first comment everything is fine. Did you test it with emulator?

Yes, everything is up to date, i have tools for 27,28,29. And yes i have tried on emulator too, giving me the same issue :(

kalismeras61 commented 5 years ago

The logs are not clear. Can you run adb logcat ?

pratik037 commented 5 years ago

The logs are not clear. Can you run adb logcat ?

Sure thing. Sorry got caught up with something and didn't reply.

pratik037 commented 5 years ago

The logs are not clear. Can you run adb logcat ?

@kalismeras61 I am new to use adb logcat. Should I paste the entire output, or do I need to run it with specific flags?

BonchayHi5 commented 3 years ago

upgrading compileSdkVersion 29 woked for me