Android Question biometric library error

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Using the lib and example of : https://www.b4x.com/android/forum/threads/biometricmanager-biometric-authentication.111256/
b4a 10.7 install from scratch, last SKD and so on...
Running on a S7
Pressing the Authenticate button...
Im getting the following error
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.NoSuchFieldError: No static field colorError of type I in class Landroidx/biometric/R$attr; or its superclasses (declaration of 'androidx.biometric.R$attr' appears in /data/app/b4a.example-Yv-9jn5OKLdjKgxHNQKoKw==/base.apk)
at androidx.biometric.FingerprintDialogFragment$Api26Impl.getColorErrorAttr(FingerprintDialogFragment.java:440)
at androidx.biometric.FingerprintDialogFragment.onCreate(FingerprintDialogFragment.java:161)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2685)
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368)
at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447)
at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2181)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2004)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861)
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

How to solve this?
Thanks
 

LucaMs

Expert
Licensed User
Longtime User
Delete your SDK and
"Easy" to say it, but...
1618834243962.png


I tried to delete all Android folder but... the operation fails because apparently a file is open and in use (but who knows what! This nice Windows doesn't specify which file :mad::mad::mad:). Only possible attempt: restart the PC (30 MINUTES) and try again!

"See" you later :mad::mad::mad:
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
"Easy" to say it, but...


I tried to delete all Android folder but... the operation fails because apparently a file is open and in use (but who knows what! This nice Windows doesn't specify which file :mad::mad::mad:). Only possible attempt: restart the PC (30 MINUTES) and try again!

"See" you later :mad::mad::mad:

Yo have the ADB.exe running, open the task manager and delete it
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It seems like a bug or a new dependency in the latest version of AndroidX.
The activity must be an AppCompat activity:
1. Main:
B4X:
#AdditionalJar: androidx.biometric:biometric
#Extends: android.support.v7.app.AppCompatActivity
#AdditionalJar: androidx.arch.core:core-runtime
#AdditionalJar: androidx.appcompat:appcompat
2. Manifest:
B4X:
AddPermission(android.permission.USE_BIOMETRIC)
AddPermission(android.permission.USE_FINGERPRINT)
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
    </style>
</resources>
)

Tested on Android 8 and 11.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Those components, however, contain only platform 30. I guess I can get the 29 from the old folder, right?
You don't need 29.

This isn't a problem with B4XPages, right?
AppCompat is indeed less recommended with B4XPages. I will post a B4XPages example.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
It seems like a bug or a new dependency in the latest version of AndroidX.
The activity must be an AppCompat activity:
1. Main:
B4X:
#AdditionalJar: androidx.biometric:biometric
#Extends: android.support.v7.app.AppCompatActivity
#AdditionalJar: androidx.arch.core:core-runtime
#AdditionalJar: androidx.appcompat:appcompat
2. Manifest:
B4X:
AddPermission(android.permission.USE_BIOMETRIC)
AddPermission(android.permission.USE_FINGERPRINT)
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
    </style>
</resources>
)

Tested on Android 8 and 11.
Maybe I also should remove:

CreateResourceFromFile(Macro, Themes.DarkTheme)

from the Manifest.
 
Upvote 0
Top