NiklasMerz / cordova-plugin-fingerprint-aio

Cordova Plugin for fingerprint sensors (and FaceID) with Android and iOS support
https://www.npmjs.com/package/cordova-plugin-fingerprint-aio
MIT License
323 stars 188 forks source link

Plugin not working on Android (Build.VERSION_CODES.Q, AndroidX) #317

Open mycatnamedweb opened 3 years ago

mycatnamedweb commented 3 years ago

Bug report

I use this plugin in my App on iOS and it is working well in production. I encountered multiple issues though trying to make this plugin work on Android (and for now I parked it).

These are the issues:

Issue 1: the compilation failed because it did not recognize the symbol: Build.VERSION_CODES.Q

What I tried:

Workaround that got me past this issue: I cloned this plugin and manually replaced Build.VERSION_CODES.Q with the number 28. Loading this modified plugin from the file system got me past that failure.


Issue 2: compilation failed due to non supported version of cordova-android. Solution: upgraded from cordova-android 8.1.0 to 9 (other plugins broke so I temporarily removed them in order to first prove that I could make this plugin work on Android).


Issue 3.:

[Gradle Properties] Detected Gradle property "android.useAndroidX" with the value of "true", Cordova's recommended value is "false"
[Gradle Properties] Detected Gradle property "android.enableJetifier" with the value of "true", Cordova's recommended value is "false"
  No Java files found that extend CordovaActivity.
npm ERR! code ELIFECYCLE
npm ERR! errno 1

Which files use androidx:

$ grep -r androidx plugins
plugins/cordova-plugin-fingerprint-aio/src/android/CryptographyManagerImpl.java:import androidx.annotation.RequiresApi;
plugins/cordova-plugin-fingerprint-aio/src/android/Fingerprint.java:import androidx.biometric.BiometricManager;
plugins/cordova-plugin-fingerprint-aio/src/android/build.gradle:    implementation "androidx.biometric:biometric:1.0.1"
plugins/cordova-plugin-fingerprint-aio/src/android/BiometricActivity.java:import androidx.annotation.NonNull;
plugins/cordova-plugin-fingerprint-aio/src/android/BiometricActivity.java:import androidx.annotation.Nullable;
plugins/cordova-plugin-fingerprint-aio/src/android/BiometricActivity.java:import androidx.appcompat.app.AppCompatActivity;
plugins/cordova-plugin-fingerprint-aio/src/android/BiometricActivity.java:import androidx.biometric.BiometricPrompt;
plugins/cordova-plugin-fingerprint-aio/src/android/BiometricActivity.java:import androidx.core.content.ContextCompat;

What I tried:

UPDATE: Using cordova-plugin-androidx it managed to correctly compile this plugin.

I am now stuck with this error (my min sdk version is already 24). This may be unrelated to this plugin.

> Task :app:processDebugManifest FAILED
web-nj/platforms/android/app/src/main/AndroidManifest.xml Error:
        uses-sdk:minSdkVersion 19 cannot be smaller than version 22 declared in library [:CordovaLib] web-nj/platforms/android/CordovaLib/build/intermediates/library_manifest/debug/AndroidManifest.xml as the library might be using APIs not available in 19
        Suggestion: use a compatible library with a minSdk of at most 19,
                or increase this project's minSdk version to at least 22,
                or use tools:overrideLibrary="org.apache.cordova" to force usage (may lead to runtime failures)

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

FAILURE: Build failed with an exception.

BUILD FAILED in 1m 46s
14 actionable tasks: 14 executed
Command failed with exit code 1: web-nj/platforms/android/gradlew cdvBuildDebug -b web-nj/platforms/android/build.gradle

NOTE: The error "No Java files found that extend CordovaActivity" intermittently came back despite the use of cordova-plugin-androidx and cordova-plugin-androidx-adapter.

At this point, I would have to edit the plugin to not use androidx or revert to an older version (but according to the git history that would introduce other bugs). For now, I have to park this due to other priorities.

Environment

Cordova Packages:

    cli: 10.0.0
        common: 4.0.2
        create: 3.0.0
        lib: 10.0.0
            common: 4.0.2
            fetch: 3.0.0
            serve: 4.0.0

Project Installed Platforms:

    android: 9.0.0
    ios: 5.1.1

    OS: macOS Mojave 10.14.6 (18G95) (darwin 18.7.0) x64
    Node: v12.16.1
    npm: 6.13.4

Xcode 11.3.1

Available Android targets:
----------
id: 1 or "android-27"
     Name: Android API 27
     Type: Platform
     API level: 27
     Revision: 3
----------
id: 2 or "android-28"
     Name: Android API 28
     Type: Platform
     API level: 28
     Revision: 6
----------
id: 3 or "android-29"
     Name: Android API 29
     Type: Platform
     API level: 29
     Revision: 4          
NiklasMerz commented 3 years ago

The latest version of this plugin uses AndroidX. You need the latest version of cordova-android to get this working. Also if you have plugins that are using the support library you can use the cordova androidx adapter plugin to get them working with AndroidX

This should not be a bug but an issue with projects not ready for AndroidX

mycatnamedweb commented 3 years ago

I did try cordova-plugin-androidx-adapter too and it did not help, same result :(

sureshreddis commented 3 months ago

Tried with cordova androidx adapter plugin but still the issue exists, @NiklasMerz Can you please suggest if there is any work around for this issue when using AndroidX.