Android Question Admob crash

Himred

Member
Licensed User
Longtime User
Hello,

I followed all the steps ie:
- Copied the google service jar
- Got my API key / AdMob ID
- Edited the manifest
- Added the additional res
- Added AddMob library

Everything compiles correctly but when I execute the app it crashes.

Here is the code:
B4X:
    #Region  Project Attributes
    #ApplicationLabel: MobAppTest
    #VersionCode: 40
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: true
    #IncludeTitle: false
    #AdditionalRes: C:\Users\Me\Documents\Coding\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#End Region

Sub Process_Globals
End Sub

Sub Globals
    Dim AdView1 As AdView
End Sub

Sub Activity_Create(FirstTime As Boolean)
 
    AdView1.Initialize2("Ad", "ca-app-pub-MYIDHIDDEN", AdView1.SIZE_SMART_BANNER)
    Dim Height As Int
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
          If 100%x > 100%y Then Height = 32dip Else Height = 50dip
    Else
          Height = 90dip
    End If
    Activity.AddView(AdView1, 0dip, 100%y - Height, 100%x, Height)
    AdView1.LoadAd
End Sub

Sub Activity_Resume
AdView1.Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
AdView1.Pause
End Sub

Sub Ad_FailedToReceiveAd (ErrorCode As String)
    Log("failed: " & ErrorCode)
End Sub
Sub Ad_ReceiveAd
    Log("received")
End Sub
Sub Ad_AdScreenDismissed
  Log("screen dismissed")
End Sub

It crash even if I comment Adview1.LoadAd

Any idea how I can find the reason ?

I use google play service API 19 and B4A 3.20

Regards,

Himred
 

strat

Active Member
Licensed User
Longtime User
Without error message, nobody can help you. Please run debug mode and type error line(s) here.
 
Upvote 0

Himred

Member
Licensed User
Longtime User
Here is what I get in debug mode:

B4X:
Error occurred on line: 0 (null)
java.lang.ClassNotFoundException: anywheresoftware$b4a$admobwrapper$AdViewWrapper
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:393)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:365)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:247)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:174)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at com.himred.shapes.main.initializeGlobals(main.java:263)
    at com.himred.shapes.main.afterFirstLayout(main.java:95)
    at com.himred.shapes.main.access$100(main.java:16)
    at com.himred.shapes.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)

This does not help me ;(

Any expert help would be appreciated.

Thanks in advance.

Himred
 
Upvote 0

eps

Expert
Licensed User
Longtime User
This ClassNotFoundException seems to hint at the Class not being found. I think you need to check and double check that the libraries are in the locations that you think they are and that they are accessible.
 
Upvote 0
Top