kloder-games / godot-admob

Module Admob for Godot engine
MIT License
362 stars 62 forks source link

Admob is not detected in 3.1.1 #108

Open wamiqurrehman093 opened 4 years ago

wamiqurrehman093 commented 4 years ago

OS target (Android/iOS): Android

Godot version: 3.1.1

Issue description:

I compiled my own templates and tried this as well [ https://github.com/Shin-NiL/godot-custom-mobile-template/releases ] and put it in my custom package debug and release paths on android export window and also put the:

[android]
modules="org/godotengine/godot/GodotAdMob"

but still I get false whenever I try to load the Admob print(Engine.has_singleton("GodotAdMob"))

Shin-NiL commented 4 years ago

Open your project.godot file and check again to see if your changes stills there. If you edit this file with the godot editor open, it most likely was overwritten. Edit and save the file with the Godot editor closed then try again.

wamiqurrehman093 commented 4 years ago

yes it has these lines

[android]
modules="org/godotengine/godot/GodotAdmob"
Shin-NiL commented 4 years ago

Does the example project work?

Shin-NiL commented 4 years ago

Oh, I see, the singleton name is AdMob:

Engine.has_singleton("AdMob")

wamiqurrehman093 commented 4 years ago

example is not working and yes I tried that too but didn't work then I put "GodotAdMob" and still didn't work

wamiqurrehman093 commented 4 years ago

wait rewarded video worked on example when I deployed on my phone

wamiqurrehman093 commented 4 years ago

only reward video worked nothing else

wamiqurrehman093 commented 4 years ago

interstitial and banners not working

Shin-NiL commented 4 years ago

Take a look at the logs using logcat. The example is working fine to me.

Gnumaru commented 4 years ago

Could it be something related to the admob network? Some days ago my project was running fine. This morning my project was showing the admob test banners but crashed when trying to show the interstitials. Some time later the project starting crashing always. After some tests I discovered that even though "Engine.has_singleton('AdMob')" was returning true, when I tried "Engine.get_singleton('AdMob')" the game crashed. Here is the relevant part of the logcat messages

D/AndroidRuntime( 4808): Shutting down VM

E/AndroidRuntime( 4808): FATAL EXCEPTION: main

E/AndroidRuntime( 4808): Process: com.mycompany.mygame, PID: 4808

E/AndroidRuntime( 4808): java.lang.NullPointerException: Attempt to invoke virtual method 'int com.google.android.gms.ads.AdView.getVisibility()' on a null object reference

E/AndroidRuntime( 4808):    at org.godotengine.godot.GodotAdMob$5.run(GodotAdMob.java:286)

E/AndroidRuntime( 4808):    at android.os.Handler.handleCallback(Handler.java:739)

E/AndroidRuntime( 4808):    at android.os.Handler.dispatchMessage(Handler.java:95)

E/AndroidRuntime( 4808):    at android.os.Looper.loop(Looper.java:135)

E/AndroidRuntime( 4808):    at android.app.ActivityThread.main(ActivityThread.java:5293)

E/AndroidRuntime( 4808):    at java.lang.reflect.Method.invoke(Native Method)

E/AndroidRuntime( 4808):    at java.lang.reflect.Method.invoke(Method.java:372)

E/AndroidRuntime( 4808):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

E/AndroidRuntime( 4808):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

W/ActivityManager( 1725):   Force finishing activity 1 com.mycompany.mygame/org.godotengine.godot.Godot

E/EGL_emulation( 1422): tid 1422: eglCreateSyncKHR(1479): error 0x3004 (EGL_BAD_ATTRIBUTE)

W/WindowManager( 1725): updateFocusedWindowLocked, focusedAppToken is null.

E/EGL_emulation( 1422): tid 1422: eglCreateSyncKHR(1479): error 0x3004 (EGL_BAD_ATTRIBUTE)

D/SurfaceFlinger( 1422): setOrientation, mFbdev=0xb68616c0, mFbDev->setOrientation=0xb7002060, orientation=0
Gnumaru commented 4 years ago

I managed to solve my problem. I was trying to get the admob singleton on a _ready function of another singleton. I moved to logic to a _ready function of a normal object and it worked fine. Oddly, my setup was working before but then stopped working without reason. It could be something related to the loading order of the singletons and the time needed to setup the admob java objects from the java side.

carcedogames commented 4 years ago

Can someone provide me with the .exe with the admob module already compiled?, Thanks

Shin-NiL commented 4 years ago

@Gnumaru this module is working only up to Godot 3.1.1. If you use Godot 3.2 master, it'll crash.

@carcedogames you can find precompiled modules here.

Gnumaru commented 4 years ago

@Gnumaru this module is working only up to Godot 3.1.1. If you use Godot 3.2 master, it'll crash.

Sorry, I forgot to mention these informations. I'm using the oficial 64 bit windows build of latest stable standard (without mono) version of godot, 3.1.1. Nevertheless my problem now seems urelated to this one since for @wamiqurrehman093 even Engine.has_singleton("GodotAdMob") is returning false whereas for me it returned true. I just wanted to point a possible correlation of the two problems but now it doesn't seem to be the case anymore.

gumaciel commented 4 years ago

@Gnumaru @wamiqurrehman093 the problem still persists?