mjwheatley / cordova-plugin-android-fingerprint-auth

A cordova plugin for fingerprint authentication using the hardware fingerprint scanner on devices running Android 6+
Apache License 2.0
168 stars 131 forks source link

package android.hardware.fingerprint does not exist #97

Closed DanceSC closed 6 years ago

DanceSC commented 6 years ago

I am having a similar issue to this thread: https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth/issues/71

After adding the "cordova-plugin-android-fingerprint-auth" plugin. I couldn't get it to build without errors, after some researching and testing of different gradle builds I updated the gradle classpath to gradle:2.3.2 and it prompted me with " we strongly recommend that you update the Android Gradle plugin to version 3.0.1 and Gradle to version 4.1." I clicked "Update" and it seems like nothing has happened, but this is what I have:

File->Settings->Build,Execution,Deployment->Gradle is set to "Use default gradle wrapper (recommended)" File->ProjectStructure->Project Gradle version: 4.1 Android Plugin Version: (empty)

On build.gradle (Module: android):

dependencies { classpath 'com.android.tools.build:gradle:2.3.2' } task wrapper(type: Wrapper) { gradleVersion = '2.3.2' }

On gradle-wrapper.properties: distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

On AndroidManifest.xml:

When I click Run these are just some of the errors that I get: Error:(19, 36) error: package android.hardware.fingerprint does not exist Error:(21, 33) error: package android.security.keystore does not exist Error:(22, 33) error: package android.security.keystore does not exist Error:(71, 13) error: cannot find symbol class FingerprintManager Error:(581, 58) error: package FingerprintManager does not exist

Any advise?

mjwheatley commented 6 years ago

Does it work if you don't update the gradle plugin and keep using 2.3.2?

DanceSC commented 6 years ago

I couldn't get it to work on any version. I ended up updating the version to 2.3.2 and still no luck. I just changed it back to 2.3.2 to see...

DanceSC commented 6 years ago

Should my minSdkVersion or targetSdkVersion be higher than 14 and 22 respectively? I have my project gradle version currently set to 3.3 and the build.gradle files are using the classpath com.android.tools.build:gradle:2.3.2

mjwheatley commented 6 years ago

You need to Target SDK 23 or higher.

DanceSC commented 6 years ago

Okay! Trying that now

DanceSC commented 6 years ago

Am I doing this right? I am still getting the same error messages as before <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" />

DanceSC commented 6 years ago

in FingerprintAuth.java these 4 lines are the first one that are giving me issues:

import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
mjwheatley commented 6 years ago

Please report if the following works for you.

cordova android --version

7.1.0

cordova create fingerprint-auth com.example.android.fingerprint.auth FingerprintAuth
cd fingerprint-auth
cordova platform add android
cordova run android

fingerprint-auth/platforms/android/build/outputs/apk/android-debug.apk Package name: com.example.android.fingerprint.auth LAUNCH SUCCESS

cordova plugin add cordova-plugin-android-fingerprint-auth

Installing "cordova-plugin-android-fingerprint-auth" for android ANDROID_HOME=/Users/mjwheatley/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home Subproject Path: CordovaLib The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead. at build_aajdgym9qzqw7kh0fv4shjz41.run(/Users/mjwheatley/Development/Cordova/apps/fingerprint-auth/platforms/android/build.gradle:141) The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0. Incremental java compilation is an incubating feature. The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead. :clean :CordovaLib:clean

BUILD SUCCESSFUL

Total time: 1.492 secs Adding cordova-plugin-android-fingerprint-auth to package.json Saved plugin info for "cordova-plugin-android-fingerprint-auth" to config.xml

DanceSC commented 6 years ago

cordova android --version returns 5.3.3, let me look into updating that

DanceSC commented 6 years ago

That worked! I had to install a newer version of node js in order to run

npm install -g cordova@latest

and I got LAUNCH SUCCESS and BUILD SUCCESS after both the

cordova android run

and

cordova plugin add cordova-plugin-android-fingerprint-auth

When I load the project in Android Studio it still prompts me with "To take advantage of all the latest features (such as Instant Run), improvements and security fixes, we strongly recommend that yo update the Android Gradle plugin to version 3.0.1 and Gradle to version 4.1"

Thank you so much for your help! It looks like it was the Android version and issues with my Gradle versions.

When I opened it in Android Studios I got a couple errors saying:

unable to resolve dependency for ':@debug/compileclasspath': could not resolve project :cordovalib. could not resolve project :cordovalib.

I found the issue, when updating to Android 3.0 there were still migration issues in my build.gradle file. For anyone who is having similar issues, this is what fixed the unable to resolve dependency issues: https://stackoverflow.com/questions/33718663/gradle-error-configuration-declares-dependency-which-is-not-declared

mjwheatley commented 6 years ago

Glad you got it working.