kloder-games / godot-admob

Module Admob for Godot engine
MIT License
360 stars 61 forks source link

Exported application doesn't work #33

Closed mjablecnik closed 6 years ago

mjablecnik commented 6 years ago

OS target (Android/iOS): Android 8.1.0

Godot version: v3.0.2.stable.official

Issue description:

Hello I tried add banner into my Android application, but when I export and run on mobile so it fall down and cannot run it..

I progressed by your manual in README:

1) I cloned this repository and added admob directory into modules in godot source and built the apk release files. 2) Added config for android in project.godot, restarted Godot and added this code into my app:

var admob = null
var isReal = false
var isTop = false
var adBannerId = "ca-app-pub-8376690330172162/3506453875" 

func _ready():
    if(Engine.has_singleton("AdMob")):
        admob = Engine.get_singleton("AdMob")
        admob.init(isReal, get_instance_id())
        loadBanner()

func loadBanner():
    if admob != null:
        admob.loadBanner(adBannerId, isTop)
        admob.showBanner()

3) In export I setuped:

Options:
    Custom Package:
        - place your apk from build
    Permissions on:
        - Access Network State
        - Internet

I tried also your examples for Godot 3 but it also didn't work..

Shin-NiL commented 6 years ago

Please attach the result of the following command while running your app: adb logcat -s godot

mjablecnik commented 6 years ago

@Shin-NiL result is:

martin at martin-pc godot-admob >>> adb logcat -s godot                                 
- waiting for device -
^C
martin at martin-pc godot-admob >>> adb devices -l                                      
List of devices attached

martin at martin-pc godot-admob >>> adb usb                                            
error: device not found

I am not big android developer.. I am not using adb and similar special tools for install or debuging it on mobile. I develop it in Godot on computer (by F5) then export it and test app by steps: 1) Export app in Godot for Android 2) Connect my phone via USB 3) Move app.apk file from my PC on android in file manager 4) On mobile Run the apk file and it will be installed and opened.

Thats all.. and I don't know adb.. :-/

Shin-NiL commented 6 years ago

I got, but for debugging you should use adb via command line ;)

The first thing you must do is to enable the adb debugging in your device, so you can run the command I sent you before.

mjablecnik commented 6 years ago

@Shin-NiL Ok so I installed right version of adb and connect it to my mobile.. :) When I run the application so adb logcat -s godot show me:

05-06 19:58:10.412 12391 12391 I godot   : **INIT EVENT! - 0xeb3b12a0
05-06 19:58:10.412 12391 12391 I godot   : ***************** HELLO FROM JNI!!!!!!!!
05-06 19:58:10.412 12391 12391 I godot   : *******CLASS FOUND!!!
05-06 19:58:10.412 12391 12391 I godot   : STEP2, 0x1f26
05-06 19:58:10.412 12391 12391 I godot   : STEP3 -333987804
05-06 19:58:10.412 12391 12391 I godot   : STEP4, 0x81
05-06 19:58:10.412 12391 12391 I godot   : STEP4.5, 0x1f36
05-06 19:58:10.412 12391 12391 I godot   : STEP7
05-06 19:58:10.412 12391 12391 I godot   : STEP8
05-06 19:58:10.412 12391 12391 I godot   : *******GOT METHOD _dir_open ok!!
05-06 19:58:10.412 12391 12391 I godot   : *******GOT METHOD _dir_next ok!!
05-06 19:58:10.412 12391 12391 I godot   : *******GOT METHOD _dir_close ok!!
05-06 19:58:10.412 12391 12391 I godot   : *******GOT METHOD _dir_is_dir ok!!
05-06 19:58:10.412 12391 12391 I godot   : starting to attempt get methods
05-06 19:58:10.413 12391 12391 I godot   : *******GOT METHOD _init_audio ok!!
05-06 19:58:10.413 12391 12391 I godot   : *******GOT METHOD _write_buffer ok!!
05-06 19:58:10.413 12391 12391 I godot   : *******GOT METHOD _quit ok!!
05-06 19:58:10.413 12391 12391 I godot   : *******GOT METHOD _pause ok!!
05-06 19:58:10.413 12391 12391 I godot   : test construction 5
05-06 19:58:10.413 12391 12391 I godot   : running from dir /
05-06 19:58:10.497 12391 12419 I godot   : **SETUP
05-06 19:58:10.497 12391 12419 I godot   : CMDLINE LEN 0 - APK EXPANSION 0
05-06 19:58:10.526 12391 12419 I godot   : *****SETUP OK
05-06 19:58:10.527 12391 12419 I godot   : ANDROID MODULES : org/godotengine/godot/GodotAdMob
05-06 19:58:10.528 12391 12419 I godot   : mod count: 1
05-06 19:58:10.528 12391 12419 I godot   : LOADING MODULE: org/godotengine/godot/GodotAdMob
05-06 19:58:10.529 12391 12419 E godot   : **ERROR**: Couldn't find singleton for class: org/godotengine/godot/GodotAdMob
05-06 19:58:10.529 12391 12419 E godot   :    At: platform/android/java_glue.cpp:887:_initialize_java_modules() - Condition ' !singletonClass ' is true. Continuing..:

Here I am adding the apk file which I am adding into export as template: android_release.apk.zip

Shin-NiL commented 6 years ago

Here's the problem:

05-06 19:58:10.528 12391 12419 I godot   : LOADING MODULE: org/godotengine/godot/GodotAdMob
05-06 19:58:10.529 12391 12419 E godot   : **ERROR**: Couldn't find singleton for class: org/godotengine/godot/GodotAdMob

Godot can't find the module code. I can think in two possible causes for that: 1 - you forgot to put the module files in the module directory before building your custom template; 2 - you forgot to point your custom template in the project export options (debug & release):

sem titulo

mjablecnik commented 6 years ago

@Shin-NiL Thank you, I had the apk in custom_package/release. I tried move it into custom_package/debug and now it works.. I don't understand it, because I built it by commands:

scons platform=android target=release
cd platform/android/java
./gradlew build

And I thought that it give me apk file for Release..

mjablecnik commented 6 years ago

Yes I had enabled Export with Debug and I didn't know it.. Now I need add it into Debug section instead of Release until I disable it..

mjablecnik commented 6 years ago

@Shin-NiL Now I have another problem.. The adverts was showed only one and now not. Game is normal running without adverts and into log shows:

$ adb logcat -s godot
05-07 10:08:24.526  6778  6874 I godot   : Loading module: org/godotengine/godot/GodotAdMob
05-07 10:08:24.604  6778  6874 I godot   : OpenGL ES 3.0 Renderer: Adreno (TM) 505
05-07 10:08:24.724  6778  6778 I godot   : WARNING: not found: display/driver/keep_screen_on
05-07 10:08:26.036  6778  6874 D godot   : AdMob: init
05-07 10:08:28.121  6778  6778 W godot   : AdMob: onAdFailedToLoad -> ERROR_CODE_NO_FILL
Shin-NiL commented 6 years ago

This is a common issue with Admob, but out of the scope to this module. Here's the description on the API page:

ERROR_CODE_NO_FILL: The ad request was successful, but no ad was returned due to lack of ad inventory.

mjablecnik commented 6 years ago

@Shin-NiL Ok so I discovered that this error is showing after when I click to the ad banner.. And after maybe 1 hour it is working again.. So I think that this issue I can close and thank you very much for your help.. :)

bilgehannevruz commented 5 years ago

Hey, i aslo compiled my godot source code but how will i put that admob module to modules folder. I have godot 3 and it works without any file dependence. Therefore even if i compiled with admob module.. how it will be connected with the one i use? or should i do something different?