Jump to content
TTSander

Custom classes.dex in D12

Recommended Posts

I'm trying to generate a custom classes.dex file for our android app because I need to include a specific .jar-file, but I'm having trouble locating all the necessary files. I've done this before following this documentation, but I'm now unable to locate the required android-support-v4.jar. Is this no longer included with Delphi 12?

Share this post


Link to post
5 minutes ago, TTSander said:

I'm trying to generate a custom classes.dex file for our android app because I need to include a specific .jar-file

What is the jar file, and is there some reason why just adding the jar to the project is not sufficient?

Share this post


Link to post

It's an SDK for connecting to the barcode scanner of MovFast-handhelds. I extracted the .jar-file from the supplied .aar file, added it to the project and generated a Delphi interface using Winsoft JavaImport for Android, but this hasn't worked so far. No errors or anything, calling functions from the SDK simply doesn't do anything. I ran into this issue a few years ago, in which case including the .jar-file in classes.dex was the solution. Therefore, I wanted to try and see if this would also work for this library.

Share this post


Link to post
2 hours ago, TTSander said:

It's an SDK for connecting to the barcode scanner of MovFast-handhelds. I extracted the .jar-file from the supplied .aar file

I've tried searching for this with not much success. Do you have a link?

Share this post


Link to post

This is the GitHub-page for the demo-app and documentation. It doesn't include the .aar file, but we received that from our supplier. I'm not sure if I can share that here.

 

The interface generated for the XCBarcodeScanner class looks like this.

 

First I call

TJXcBarcodeScanner.JavaClass.init;

Although I'm not sure if that's actually necessary. I'm not adding a listener here, since we capture the intents broadcasted by the barcode scanner service.

 

Then when I call

TJXcBarcodeScanner.JavaClass.startScan;

nothing happens.
 

Share this post


Link to post
Posted (edited)
42 minutes ago, TTSander said:

Then when I call


TJXcBarcodeScanner.JavaClass.startScan;

nothing happens.

Does this mean you've moved on from attempting to generate a custom classes.dex?

 

Going by their documentation, the init method needs to be called. (the one that takes a Context and a ScannerResult as parameters). This may present a problem because Delphi uses init as a method name for Java constructors, and XcBarcodeScanner has its own static method called init (which is not a constructor), so the JNI code may actually try and find a constructor method (and fail) rather than the actual method called init. I'm not sure if there's a solution for this yet, other than writing Java code of your own (that you would call from Delphi) that uses the XcBarcodeScanner class.

 

Incidentally, I've managed to acquire the .jar file myself using information from the Github link you gave. 

Edited by Dave Nottage

Share this post


Link to post

Well, I havent made any further attempts to create á custom classes.dex since my original issue (the missing android-support-v4.jar) hasn't been solved. I just attempted to use the XCScanner-libray by including the .jar file in the project.
I was afraid the init method might be the issue here, and judging by what you say the solution will not be trivial. Given the fact that this is not a pressing issue right now and the customer will use the hardware buttons on the device to trigger the barcode reader anyway I think I'll park the issue for now.

 

Thanks for your help and insights!

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×