Hello!
I’ve encountered a problem with my project after i added the admob extension (https://github.com/defold/extension-admob/archive/master.zip) that causes the app that i’ve build to crash with the following message(taken from adb logcat):
08-06 19:59:39.161 14065 14065 D AndroidRuntime: Shutting down VM
08-06 19:59:39.161 14065 14065 E AndroidRuntime: FATAL EXCEPTION: main
08-06 19:59:39.161 14065 14065 E AndroidRuntime: Process: com.TBCtalents, PID: 14065
08-06 19:59:39.161 14065 14065 E AndroidRuntime: java.lang.IllegalStateException: View android.widget.LinearLayout{df59b0a V.E… …I. 0,0-840,168} has already been added to the window manager.
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:370)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:96)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at com.defold.admob.AdmobJNI$9.run(AdmobJNI.java:489)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7682)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
08-06 19:59:39.161 14065 14065 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Information about the project:
My project is a Talent calculator for The burning crusade classic (just needed something to create while learing defold/LUA and it was the first thing that came to mind). During the building of my app i’ve been bundling and deploying to my phone and also had some testers using the app and so far not encountered any major issues.
The problem:
After adding the admob exstension to my app the app crashed when running admob.show_banner(admob.POS_TOP_CENTER). I’ve also tried admob.show_banner(admob.POS_BOTTOM_CENTER) with the same result. I did some testing adding wrong unit ID’s and such. In those situations i get the prompted that the unit ID is wrong when trying to initialize or loading the banner. When using the correct ID’s i can set callback, initialize and load banner like so:
if admob then
admob.set_callback(admob_callback)
admob.initialize()
admob.load_banner(self.banner_ad_unit)
end
When i do this i get printed message from intialization and loading that everything seems fine:
08-08 15:05:01.645 17523 17563 D defold : DEBUG:SCRIPT: EVENT_COMPLETE: Initialization complete
08-08 15:05:03.668 17523 17563 D defold : DEBUG:SCRIPT: EVENT_LOADED: Banner AD loaded. Height: 168px Width: 1078px
08-08 15:05:03.668 17523 17563 D defold : DEBUG:SCRIPT: EVENT_IMPRESSION_RECORDED: Banner did record impression
When i fire of the admob.show_banner(admob.POS_TOP_CENTER) method like this:
if admob.is_banner_loaded() then
print(“inside is banner loaded”)
admob.show_banner(admob.POS_TOP_CENTER)
end
the banner flashes for a split second on the top of the screen then the app crashes (as explaned in the log above).
I dont know what more i can try. I did try to find some information about the LinearLayout crash in the window manager but i feel stuck not know if there is a general problem with my project or if the problem is related to some conflict in my dependencies.
The issue is the same on two devices (Oneplus 6 and Sony Xperia 5 II) that i’ve tried and started after adding admob to the project.
Has anyone encountered something simular? I appreciate any help i can get solving this issue.
Thanks!