cgisca / PGSGP

Play Games Services plugin for Godot Game Engine - Android
MIT License
217 stars 61 forks source link

Godot cannot be cast to android.app.Activity #65

Open SanderVanhove opened 3 years ago

SanderVanhove commented 3 years ago

Godot version: 3.3.2

When I call play_games_services.init(false) I get this error in my logcat:

AndroidRuntime: Process: com.sandervanhove.bouncybox, PID: 27870
AndroidRuntime: java.lang.ClassCastException: org.godotengine.godot.Godot cannot be cast to android.app.Activity
AndroidRuntime:        at io.cgisca.godot.gpgs.PlayGameServicesGodot.initialize(PlayGameServicesGodot.kt:185)
AndroidRuntime:        at io.cgisca.godot.gpgs.PlayGameServicesGodot.init(PlayGameServicesGodot.kt:168)
AndroidRuntime:        at org.godotengine.godot.GodotLib.step(Native Method)
AndroidRuntime:        at org.godotengine.godot.GodotRenderer.onDrawFrame(GodotRenderer.java:60)
AndroidRuntime:        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1582)
AndroidRuntime:        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1281)

Maybe this is related to https://github.com/godotengine/godot/issues/47198.

SanderVanhove commented 3 years ago

Probably these lines should be updated:

https://github.com/cgisca/PGSGP/blob/8a47c95620c58c4d357ed50aef2e2c722a875050/app/src/main/java/io/cgisca/godot/gpgs/PlayGameServicesGodot.kt#L185-L194

Clooloo commented 3 years ago

I get this same error, How to update these lines? it is not on my project.

SanderVanhove commented 3 years ago

So what I did was cloned the repo, altered the line, made it depend on Godot 3.3.2 and rebuild the plugin. That did the trick. But it is in no shape to be made in a PR I'm afraid because I didn't really know what I was doing.

vipulbehl commented 3 years ago

Hi @SanderVanhove

Would it be possible for you to create a branch(of the changes you made) and share here. Seems like lot of people are facing the same issue.

HardcoreMuse commented 3 years ago

Facing the same issue here...would appreciate some assistance.

vipulbehl commented 3 years ago

Use https://github.com/cgisca/PGSGP/pull/63

This PR has support for 3.3.2

SanderVanhove commented 3 years ago

Whoops sorry for reacting so late 😅 Yeah that PR seems to implement the right changes.