Android Question HMS ads "java.lang.RuntimeException: Constructor not found."

Almora

Active Member
Licensed User
hi i am getting this error when applying hms ads.
The example of b4xpage works fine, but when I put it back to normal, it causes an error. what would be the reason.

Error occurred on line: 74 (HMSManager)
java.lang.RuntimeException: Constructor not found.
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:94)
at b4a.exampleddd.hmsmanager._createlistener(hmsmanager.java:429)
at b4a.exampleddd.hmsmanager._createbannerad(hmsmanager.java:115)
at b4a.exampleddd.tt._activity_create(tt.java:375)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.exampleddd.tt.afterFirstLayout(tt.java:105)
...


B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

    
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private hms As HMSManager
    Dim iad As JavaObject
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("tt")
 

    hms.Initialize
    hms.EnableLogs
 
    Dim banner As B4XView = hms.CreateBannerAd("testw6vs28auh3", "BANNER_SIZE_320_50", Me, "Banner")
    Activity.AddView(banner, Activity.Width / 2 - 320dip / 2, Activity.Height - 50dip, 320dip, 50dip)
    hms.LoadBannerAd(banner, hms.CreateRequestBuilder)
    
    iad = hms.CreateInterstitialAd("testb4znbuh3n2", Me, "Interstitial") 'iad is a global JavaObject variable
    hms.LoadInterstitialAd(iad, hms.CreateRequestBuilder)



End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Banner_AdFailed (ErrorCode As Int)
    Log("Failed: " & ErrorCode)
End Sub

Sub Banner_AdLoaded
    Log("AdLoaded")
End Sub

Sub Banner_AdOpened
    Log("AdOpened")
End Sub



Sub Interstitial_AdFailed (ErrorCode As Int)
    Log("Failed: " & ErrorCode)
End Sub

Sub Interstitial_AdLoaded
    Log("AdLoaded")
    
End Sub

Sub Button1_Click
    iad.RunMethod("show", Null)
End Sub
 

skaliwag

Member
Licensed User
If this is a new project then use B4XPages. Everything will be simpler.

Target parameter in CreateInterstitialAd must be a class instance.
And if it isn't a new
If this is a new project then use B4XPages. Everything will be simpler.

Target parameter in CreateInterstitialAd must be a class instance.
Same problem here.
And if it is not a new project?
What should be passed to CreateInterstitialAd / CreateBannerAd if the project is not using B4XPages?
 
Upvote 0
Top