cordova-plugin-fingerprint-aio
cordova-plugin-fingerprint-aio copied to clipboard
Plugin not working on Android (Build.VERSION_CODES.Q, AndroidX)
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:
- To change the value of
<preference name="android-targetSdkVersion" value="@@" />
from 28 to 30. No luck. - Changed all
ANDROID_SUPPORT_ANNOTATIONS_VERSION
values in my config.xml to 29. No luck. - Wrote a hook that programmatically forced all versions to 29. No luck.
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:
- Set
<preference name="AndroidXEnabled" value="true" />
to true but no luck, same error.
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 CLI 10.0.0
-
Plugin version: [email protected]
-
Build 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
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
I did try cordova-plugin-androidx-adapter too and it did not help, same result :(