DelphiWorlds / Playground

Stuff I'm working on that I *may* make public
MIT License
45 stars 16 forks source link

RewardAd #8

Closed kabiri closed 2 years ago

kabiri commented 2 years ago

admob demo work but i create new FMX app


unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, DW.AdMob, DW.AdMobBannerAd, DW.AdMobAds;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    RewardAd: TRewardedAd;
    procedure AdDismissedFullScreenContentHandler(Sender: TObject);
    procedure AdFailedToShowFullScreenContentHandler(Sender: TObject; const AError: TAdError);
    procedure AdShowedFullScreenContentHandler(Sender: TObject);
    procedure UserEarnedRewardHandler(Sender: TObject; const AReward: TAdReward);
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.AdDismissedFullScreenContentHandler(Sender: TObject);
begin

end;

procedure TForm1.AdFailedToShowFullScreenContentHandler(Sender: TObject;
  const AError: TAdError);
begin

end;

procedure TForm1.AdShowedFullScreenContentHandler(Sender: TObject);
begin

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 RewardAd := TRewardedAd.Create;
 RewardAd.AdUnitId := 'ca-app-pub-2017133626224006/4023072507'; //Reward Magic
 RewardAd.OnAdDismissedFullScreenContent := AdDismissedFullScreenContentHandler;
 RewardAd.OnAdFailedToShowFullScreenContent := AdFailedToShowFullScreenContentHandler;
 RewardAd.OnAdShowedFullScreenContent := AdShowedFullScreenContentHandler;
 RewardAd.OnUserEarnedReward := UserEarnedRewardHandler;
end;

procedure TForm1.UserEarnedRewardHandler(Sender: TObject;
  const AReward: TAdReward);
begin

end;

end.

in this line " RewardAd := TRewardedAd.Create;" show error : Project Test.apk raised exception class EJNIFatal with message 'Java type com/delphiworlds/kastri/DWRewardedAdLoadCallbackDelegate could not be found'.

DelphiWorlds commented 2 years ago

As per the readme: https://github.com/DelphiWorlds/Playground/tree/main/Demos/AdMob "If creating your own project, you will need to add the dw-admob.jar file to the Libraries node under the Android platform in Project Manager"