Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Biometric] Demo Application Crash BiometricDemoD11 #88

Closed
sfoms opened this issue Jan 13, 2022 · 44 comments
Closed

[Biometric] Demo Application Crash BiometricDemoD11 #88

sfoms opened this issue Jan 13, 2022 · 44 comments
Assignees
Labels
bug Something isn't working

Comments

@sfoms
Copy link

sfoms commented Jan 13, 2022

When you press the fingerprint scanner icon, the application crashes and gives the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/biometric/R$string;
at androidx.biometric.BiometricFragment.authenticate(BiometricFragment.java:381)
at androidx.biometric.BiometricPrompt.authenticateInternal(BiometricPrompt.java:993)
at androidx.biometric.BiometricPrompt.authenticate(BiometricPrompt.java:972)
at com.delphiworlds.kastri.DWBiometricFragmentActivity.authenticate(DWBiometricFragmentActivity.java:91)
at com.delphiworlds.kastri.DWBiometricFragmentActivity.onResume(DWBiometricFragmentActivity.java:106)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1413)
at android.app.Activity.performResume(Activity.java:7400)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3850)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3890)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:150)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:73)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1858)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.biometric.R$string" on path: DexPathList[[zip file "/data/app/com.delphiworlds.BiometricDemoD11-alBMpzbi0kV5Eu8m3O07dg==/base.apk"],nativeLibraryDirectories=[/data/app/com.delphiworlds.BiometricDemoD11-alBMpzbi0kV5Eu8m3O07dg==/lib/arm, /data/app/com.delphiworlds.BiometricDemoD11-alBMpzbi0kV5Eu8m3O07dg==/base.apk!/lib/armeabi-v7a, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 19 more

Delphi Version: 11
Platform(s): Android 9 PPR1.160610.011
Device: Redmi 6, MIUI Global 11.0.5

@DelphiWorlds DelphiWorlds self-assigned this Jan 13, 2022
@DelphiWorlds DelphiWorlds added the question Further information is requested label Jan 13, 2022
@DelphiWorlds
Copy link
Owner

I'm unable to reproduce this issue on my Pixel 6 Pro (Android 12) or Pixel 3a (Android 11). I don't have an Android 9 device with biometrics to check why it happens on yours

@sfoms
Copy link
Author

sfoms commented Jan 13, 2022

When you run this function, this problem occurs:

function TPlatformBiometric.ShowPrompt: Boolean;
begin
Result := False;
if GetBiometricCapability = TBiometricCapabilityResult.Available then
begin
TJDWBiometricFragmentActivity.JavaClass.start(TAndroidHelper.Context, GetPromptInfoIntent);
Result := True;
end;
end;

And to be even more precise:

TJDWBiometricFragmentActivity.JavaClass.start(TAndroidHelper.Context, GetPromptInfoIntent);

P.S. Sorry for my English. It's not my native language...

@DelphiWorlds
Copy link
Owner

I have updated the demo with a change that may fix it. You will need to update your Kastri library to obtain all the required changes

@sfoms
Copy link
Author

sfoms commented Jan 14, 2022

I will be waiting very much. Thank you very much.

@sfoms
Copy link
Author

sfoms commented Jan 14, 2022

After the update, the error is still the same, only different:
java.lang.RuntimeException: Unable to resume activity {com.delphiworlds.BiometricDemoD11/com.delphiworlds.kastri.DWBiometricFragmentActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3858)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3890)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:150)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:73)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1858)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)

Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:360)
at android.content.res.MiuiResources.getText(MiuiResources.java:97)
at android.content.res.Resources.getString(Resources.java:453)
at androidx.fragment.app.Fragment.getString(Fragment.java:986)
at androidx.biometric.BiometricFragment.authenticate(BiometricFragment.java:382)
at androidx.biometric.BiometricPrompt.authenticateInternal(BiometricPrompt.java:993)
at androidx.biometric.BiometricPrompt.authenticate(BiometricPrompt.java:972)
at com.delphiworlds.kastri.DWBiometricFragmentActivity.authenticate(DWBiometricFragmentActivity.java:91)
at com.delphiworlds.kastri.DWBiometricFragmentActivity.onResume(DWBiometricFragmentActivity.java:106)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1413)
at android.app.Activity.performResume(Activity.java:7400)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3850)
... 11 more

@DelphiWorlds
Copy link
Owner

Sorry.. I know where the problem is. I just need to work out how to fix it :-)

@DelphiWorlds DelphiWorlds added bug Something isn't working and removed question Further information is requested labels Jan 15, 2022
@DelphiWorlds
Copy link
Owner

I've pushed an update to the biometric R jar (androidx-biometric-1.1.0.R.jar). Can you pull the change, do a Clean of your project and try again?

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

Unfortunately, I can't compile. Here's an error:

[PAClient Error] Error: E7432 Unable to execute '"C:\Program Files\AdoptOpenJDK\jdk-8.0.242.08-hotspot\bin\java.exe" -jar "c:\program files (x86)\embarcadero\studio\22.0\bin\Android\embt-d8-2.2.64.jar" --intermediate --release --min-api 23 --lib "C:\Users\Public\Documents\Embarcadero\Studio\22.0\CatalogRepository\AndroidSDK-2525-22.0.42600.6491\platforms\android-30\android.jar" --classpath-list "C:\Users\Public\Documents\Embarcadero_Comp\Kastri\Demos\Biometric\Android\Release\classpath-list.txt" --output "C:\Users\Public\Documents\Embarcadero_Comp\Kastri\Demos\Biometric\Android\Release\androidx-activity-1.3.1-dexed.jar" "C:\Users\Public\Documents\Embarcadero_Comp\Kastri\ThirdParty\Android\androidx-activity-1.3.1.jar"' (Error 1)

[PAClient Error] Error: E7432 Error in C:\Users\Public\Documents\Embarcadero_Comp\Kastri\ThirdParty\Android\androidx-biometric-1.1.0.R.jar:
[PAClient Error] Error: E7432 java.util.zip.ZipException: error in opening zip file

@DelphiWorlds
Copy link
Owner

Not sure why it would not be compiling for you - compiles OK here

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

I have updated OpenJDK to version 8.0.3.312.7 but the error remains.

Maybe you updated some more files, but did not post them? :)

@DelphiWorlds
Copy link
Owner

That's the only file that was changed

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

I don't know why, but I rebooted the computer and the project compiled. Now I'll try to run it on different devices. Thanks!

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

Error again:

java.lang.RuntimeException: Unable to resume activity {com.delphiworlds.BiometricDemoD11/com.delphiworlds.kastri.DWBiometricFragmentActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x7f070000
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3858)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3890)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:150)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:73)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1858)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f070000
at android.content.res.Resources.getText(Resources.java:360)
at android.content.res.MiuiResources.getText(MiuiResources.java:97)
at android.content.res.Resources.getString(Resources.java:453)
at androidx.fragment.app.Fragment.getString(Fragment.java:986)
at androidx.biometric.BiometricFragment.authenticate(BiometricFragment.java:382)
at androidx.biometric.BiometricPrompt.authenticateInternal(BiometricPrompt.java:993)
at androidx.biometric.BiometricPrompt.authenticate(BiometricPrompt.java:972)
at com.delphiworlds.kastri.DWBiometricFragmentActivity.authenticate(DWBiometricFragmentActivity.java:91)
at com.delphiworlds.kastri.DWBiometricFragmentActivity.onResume(DWBiometricFragmentActivity.java:106)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1413)
at android.app.Activity.performResume(Activity.java:7400)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3850)
... 11 more

On the Honor 9 phone, it also crashes (but I can’t see the error on it).

@DelphiWorlds
Copy link
Owner

DelphiWorlds commented Jan 15, 2022

Can you attach the .APK file, please?

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

BiometricDemoD11.zip

@DelphiWorlds
Copy link
Owner

I may have missed a change to the project file. Please pull the latest changes, and rebuild your project

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

Absolutely the same error... :(

Maybe try the other way around. Will you send the APK, and I will install it on my phone?

@DelphiWorlds
Copy link
Owner

Can you post a screenshot of your Deployment window? i.e. in Delphi, use Project|Deployment. It should look like this:

image

Note all the files that have been added

@DelphiWorlds
Copy link
Owner

Here is my APK so you can check if it works on your device
BiometricDemoD11.apk.zip
.

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

Snap2
Snap3
Snap1

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

Your APK also causes the application to the same error... (

@DelphiWorlds
Copy link
Owner

Without the same (or similar) device to test on, I do not think I can help at the moment

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

Is it possible to make it so that when an error occurs, the application does not crash?

Something like:
try
except

@DelphiWorlds
Copy link
Owner

DelphiWorlds commented Jan 15, 2022

Unfortunately, no - the crash actually occurs in the Java code for biometrics. Even if I could trap the exception, the code would be useless, as it would not work properly

@sfoms
Copy link
Author

sfoms commented Jan 15, 2022

What do we do? :)

@DelphiWorlds
Copy link
Owner

BiometricDemoD11.apk.zip

Can you try the attached APK?

@sfoms
Copy link
Author

sfoms commented Jan 17, 2022

Good afternoon.
The error remains the same.
I tried to change the localization of the phone (I thought it might have something to do with it), but nothing has changed...

@DelphiWorlds
Copy link
Owner

OK.. I may have a solution another way, hopefully

@sfoms
Copy link
Author

sfoms commented Jan 17, 2022

Fine! I will be very hopeful!

@DelphiWorlds
Copy link
Owner

I have just pushed a change to androidx-biometric-1.1.0-R.jar. Can you pull the change, do a Clean on your project, rebuild and try it, please? This should at least have the demo working. I am looking into implementing a solution that can apply to any project

@sfoms
Copy link
Author

sfoms commented Jan 17, 2022

Everything is fine!
Thank you very much!

@sfoms sfoms closed this as completed Jan 19, 2022
@sfoms
Copy link
Author

sfoms commented Jan 27, 2022

Hello!
There is a new problem:
On Honor X8 phone, with "Secure File Sharing" enabled, the app crashes when the fingerprint is read or canceled.

As soon as you disable "Secure File Sharing" everything works.

@DelphiWorlds
Copy link
Owner

In future, please report new issues separately, however: can you check that your AndroidManifest.template.xml file has:

<%provider%>

in it?

@sfoms
Copy link
Author

sfoms commented Jan 28, 2022

Yes, of course, <%provider%> is contained in the AndroidManifest.template.xml file

@DelphiWorlds
Copy link
Owner

Long time issue still unresolved - requires changes to the build process.

@DelphiWorlds DelphiWorlds reopened this Mar 28, 2022
@Mouscap
Copy link

Mouscap commented Jun 10, 2022

Hello,
I was previously using the KeyguardManager to authenticate the user. But as it's now deprecated, I have tried to use your BiometricDemoD11 App. I have the same issue than the one explained at the start of this discussion : When I press the fingerprint icon, the application crashes but the only error I get is "BiometricDemoD11 stopped working"... I don't know how to get more details...
When I try to execute in debug mode, the TPlatformBiometric.ShowPrompt seems to work Ok as well as the TJDWBiometricFragmentActivity.JavaClass.start(TAndroidHelper.Context, GetPromptInfoIntent) call but the process crashes after the return.
My target is Android 8.1.0 : I have read that AndroidX is supported by this platform.
Thank you for your help

Delphi Version: 11.1
Target = Android 8.1.0 - Nexus 6P

@DelphiWorlds
Copy link
Owner

Thanks for the reminder.. I've set another reminder for myself for during this week

@Mouscap
Copy link

Mouscap commented Jun 13, 2022

Thank you very much

@Mouscap
Copy link

Mouscap commented Jun 20, 2022

Hello, sorry to remind you again. Do you think you'll have some time to work on it ?

@DelphiWorlds
Copy link
Owner

Perhaps tomorrow, if not, the next day :-)

@DelphiWorlds
Copy link
Owner

I would like to be able to provide a solution for this that is easy to incorporate, however it is very complicated. If the Delphi build system was more flexible, it would be easier.

The issue is this: As you have discovered, on some devices (I do not know why it is only some), the biometrics expects there to be certain values in the application resources, however in the case of Delphi, they are not compiled in with the application. This Quality Portal report has some background about that:

https://quality.embarcadero.com/browse/RSP-20000

In Delphi, currently the build steps for Android are (essentially) like this:

Compile/Build steps:

  1. Compile/link application code
  2. Merge "dex" files

Deploy steps:

  1. Generate resource files
  2. Deploy compiled files and resources
  3. Package the app

In order for the biometrics resources to be included in the application, the steps would need to be like this:

Compile/Build steps:

  1. Compile/link application code
  2. Generate resource files
  3. Merge resources from other Android libraries (such as biometrics) with those generated by Delphi
  4. Compile "R" classes for the included libraries into a jar, and "dex" it
  5. Merge "dex" files

Deploy steps:

  1. Deploy compiled files and resources
  2. Package the app

It is possible to achieve the same result, however it involves these steps:

  1. Do a deployment once
  2. Merge resources from other Android libraries (such as biometrics) with those generated by Delphi
  3. Compile "R" classes for the included libraries into a jar, and "dex" it
  4. Add the "dexed" file to the libraries for the project
  5. In deployment manager, uncheck all the files that would normally be deployed to the "res" folder, and add the "merged" files generated in step 2. It is not an easy task to do this with Deployment Manager in its current state, however the DeployMan tool from Grijjy could help here.
  6. Do a deployment again

Usually, these steps will need to be done only once, however if any changes are made to the project that result in different resource files, steps 1-3 will definitely need to be repeated, and some changes related to step 5 may also need to be considered.

I am working on tools that can automate steps 2-3, however I'd much prefer it if Embarcadero could resolve the Quality Portal issue mentioned above

@DelphiWorlds
Copy link
Owner

@Mouscap (and anyone else following) - I have pushed a "beta" demo to the Playground repo, which you are welcome to try, and give feedback on. Please report any such feedback or issues to the Playground issues page.

@edsonalanis
Copy link

@Mouscap (and anyone else following) - I have pushed a "beta" demo to the Playground repo, which you are welcome to try, and give feedback on. Please report any such feedback or issues to the Playground issues page.

These steps only work for 32-bit Android, how to do the same for 64-bit which is the version we posted on Google Play?

@DelphiWorlds
Copy link
Owner

DelphiWorlds commented Dec 2, 2022

I specifically stated:

Please report any such feedback or issues to the [Playground issues page (https://github.com/DelphiWorlds/Playground/issues).

You even quoted the same thing in your comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants