Java Question How to expose classes from 'import' on a wrapper?

Leonidas Brasileiro

Member
Licensed User
Hello.

I'm wrting a wrapper on top of a library that uses several custom built classes that need to be exposed to the B4A app.

So far what I did is just copy their definitions at wrapper level and the B4A app compiles OK but fails to execute, throwing the stack below:

B4X:
B4A version: 6.00
Parsing code.    (0.00s)
Compiling code.    (0.73s)
Compiling layouts code.    (0.17s)
Organizing libraries.    (0.00s)
Generating R file.    (0.37s)
Compiling debugger engine code.    (1.64s)
Compiling generated Java code.    Error
B4A line: 40
myscanner.Init(Init_Data)
javac 1.8.0_91
src\lbmdata\Finger_IDer\enroll.java:384: error: incompatible types: Nurugo.InfoData cannot be converted to NurugoBSP.InfoData
mostCurrent._myscanner.Init((com.nurugo.api.NurugoBSP.InfoData)(mostCurrent._init_data));

Both classes 'InfoData' look the same in the original .jar file and in the wrapper:

B4X:
  public class InfoData
  {
    private int majorVersion;
    private int minorVersion;
   
    public InfoData() {}
   
    public int getMajorVersion()
    {
      return this.majorVersion;
    }
   
    public void setMajorVersion(int majorVersion)
    {
      this.majorVersion = majorVersion;
    }
   
    public int getMinorVersion()
    {
      return this.minorVersion;
    }
   
    public void setMinorVersion(int minorVersion)
    {
      this.minorVersion = minorVersion;
    }
  }

The only differences are that on the wrapper, I added the token for a ShortName on top of the class definition, like this:

B4X:
  @BA.ShortName("InfoData")
  public class InfoData {
.... the code ...
}

and the class definition is given inside class "Nurugo" for the wrapper and class "NurugoBSP" for the original jar file (a SDK).

Can anyone point me out in the right direction?

Thanks.
 
Top