Kotlin AAR的JAR德尔福包装器

时间:2018-07-07 12:56:54

标签: android delphi wrapper

我在.AAR中使用Android Studio编译了library,然后从.AAR中提取了.JAR。

JAVA2OP -jar evotor.jar出现错误:

解析jar:evotor.jar

模块'Java2OP.exe'中地址0042B0B6的访问冲突。读取地址7FD70000

我有包装纸

unit jdelphi;

interface

uses
  AndroidAPI.JNIBridge,
  Androidapi.JNI.JavaTypes;

type
  JUser = interface;

  JUserClass = interface(JObjectClass)
    ['{A4B29440-8C8B-4C1F-A8E7-B7612D4FEEB4}']

    function getUuid : JString; cdecl;                                         
    function hashCode : Integer; cdecl;                                        
    function init(uuid : JString; secondName : JString; firstName : JString; inn : JString; phone : JString; pin : JString; roleUuid : JString; roleTitle : JString) : JUser; cdecl; overload;
    function init(uuid : JString; secondName : JString; firstName : JString; phone : JString; pin : JString; roleUuid : JString; roleTitle : JString) : JUser; cdecl; overload;
    function toString : JString; cdecl;                                     
  end;

  [JavaSignature('ru/evotor/framework/users/User')]
  JUser = interface(JObject)
    ['{2558685B-2BDC-4FCE-901F-3B53604E37C6}']
    function equals(JObjectparam0 : JObject) : boolean; cdecl;                 
    function hashCode : Integer; cdecl;                                       
    function toString : JString; cdecl;                                       
  end;

  TJUser = class(TJavaGenericImport<JUserClass, JUser>)
  end;

implementation

procedure RegisterTypes;

begin
  TRegTypes.RegisterType('jdelphi.JUser', TypeInfo(jdelphi.JUser));
end;

initialization
  RegisterTypes;
end.

我的android程序在获取uuid值时终止。

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects,
  FMX.Platform.Android, Androidapi.JNI.JavaTypes, Androidapi.Helpers;

type
  TForm1 = class(TForm)
    btnExit: TButton;
    StyleBook1: TStyleBook;
    Text1: TText;
    btnGet: TButton;
    lbResult: TLabel;
    procedure btnExitClick(Sender: TObject);
    procedure btnGetClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

uses jdelphi;

procedure TForm1.btnExitClick(Sender: TObject);
begin
  MainActivity.finish;
end;

procedure TForm1.btnGetClick(Sender: TObject);
// var
// TestClass: JUser;
begin
  // TestClass := TJUser.Create;
  // lbResult.Text:= JStringToString(TestClass.getUuid);

  lbResult.Text := JStringToString(TJUser.JavaClass.getUuid);

end;

end.

是否可以在Delphi中使用通过这种方式获得的库(用Kotlin编写)?

0 个答案:

没有答案