GodotAds
GodotAds copied to clipboard
Error on initializing GodotAds
Hi I'm getting an error when I initialize godot ads:
platform/windows/os_windows.cpp:2532 - Condition ' !process_map->has(p_pid) ' is true. returned: FAILED
The code I have is very simple to see if I can get it working:
func _ready():
godotAds = Engine.get_singleton("GodotAds")
var instanceId = get_instance_id()
if godotAds:
godotAds.init(instanceId) # it errors here
However I get the error shown above. Any idea whats going on here?
==Info==: Compiled: Compiled from the 3.1 branch. x64 config.py settings
build = {
"admob" : True,
"adcolony" : False,
"chartboost" : False,
"vungle" : False,
"mopub" : True,
"unity_ads" : True,
"awesome_ads" : False,
"appodeal" : True,
"inmobi" : False,
}
modules/GodotAds/libs: only has the unity-ads.aar (2.1 version) Modules: "org/godotengine/godot/GodotAds" only so far The godot project GodotAdsTemplate.zip
On closer inspection this is the error that appears on logcat:
06-27 17:22:43.069: E/AndroidRuntime(23960): FATAL EXCEPTION: GLThread 491
06-27 17:22:43.069: E/AndroidRuntime(23960): Process: com.pixelfruit.godotadstemplate, PID: 23960
06-27 17:22:43.069: E/AndroidRuntime(23960): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8391)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1393)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.View.requestLayout(View.java:23279)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.View.requestLayout(View.java:23279)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.View.requestLayout(View.java:23279)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.View.requestLayout(View.java:23279)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.ViewGroup.addView(ViewGroup.java:4867)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.ViewGroup.addView(ViewGroup.java:4809)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.view.ViewGroup.addView(ViewGroup.java:4782)
06-27 17:22:43.069: E/AndroidRuntime(23960): at org.godotengine.godot.GodotAds.init(GodotAds.java:43)
06-27 17:22:43.069: E/AndroidRuntime(23960): at org.godotengine.godot.GodotLib.step(Native Method)
06-27 17:22:43.069: E/AndroidRuntime(23960): at org.godotengine.godot.GodotView$Renderer.onDrawFrame(GodotView.java:710)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1575)
06-27 17:22:43.069: E/AndroidRuntime(23960): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)
06-27 17:22:43.083: E/SensorManager(23960): unregisterListenerImpl callingApp: com.pixelfruit.godotadstemplate,callingPid:23960,callingUid:10365
Any idea whats going on?
To fix the problem I replaced the init() in /android/GodotAds.java to
public void init (final int p_script_id) {
activity.runOnUiThread(new Runnable() {
public void run() {
adLayout = new RelativeLayout(activity);
adLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
((Godot)activity).layout.addView(adLayout);
Utils.setScriptInstance(p_script_id);
}
});
}
Adding a runnable on runOnUiThread. Turns out I don't need to initialize godotads in the end to get the ads to work so even if I got this working, I removed the init in the end..
The init gave me problems to. but I was able to use admob without init.
The init gave me problems to. but I was able to use admob without init.
hola, como es eso del init