Coder Social home page Coder Social logo

cgisca / pgsgp Goto Github PK

View Code? Open in Web Editor NEW
215.0 12.0 59.0 36.86 MB

Play Games Services plugin for Godot Game Engine - Android

License: MIT License

Kotlin 100.00%
godot-engine godot-gpgs godot-play-games-services achievements leaderboards game-services player-stats saved-games google-play-game-services godot

pgsgp's Introduction

Google Play Games Services Plugin for Godot

This is an Android Play Games Services plugin for Godot Game Engine 3.2.2+.

Android Godot PGS MIT license

If you want to use the old plugin version visit Old README file.

Supported features:

  • Sign-in/Sign out
  • Achievements
  • Leaderboards
  • Events
  • Player Stats
  • Player Info
  • Saved Games

Getting started

Before using this plugin please follow instructions on Setting Up Google Play Games Services official guide.

Set up

  • Download GodotPlayGamesServices.release.aar and GodotPlayGamesServices.gdap from releases page.
  • Move the plugin configuration file (GodotPlayGamesServices.gdap) and the binary (GodotPlayGamesServices.release.aar) downloaded from the previous step to the Godot project's res://android/plugins directory.
  • Enable plugin by accessing Project -> Export, Plugins section. Follow the image.
  • Go to res://android/build directory. Add below lines to AndroidManifest.xml:
    <meta-data android:name="com.google.android.gms.games.APP_ID"
   	    android:value="@string/app_id" />
   
   	<meta-data android:name="com.google.android.gms.version"
   	   android:value="@integer/google_play_services_version"/>
  • In the same res://android/build directory,(if it is not already created) create res -> values -> Strings.xml. Add below lines to Strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    	<string name="app_id">ADD_YOUR_APP_ID</string>
</resources>

Replace ADD_YOUR_APP_ID with the app id that was generated after following instructions on Setting Up Google Play Games Services

Check demo project. In order demo project to work, replace ADD_YOUR_APP_ID with your own app id, and in Main.gd add your ids for achievements and leaderboards.

Generate plugin .aar file

If there is no release for your Godot version, you need to generate new plugin .aar file.
Follow these instruction: official documentation.

In short follow these steps:

  1. Download AAR library for Android plugins.

  2. Copy .aar file to godot-lib.release/ and rename it to godot-lib.release.aar

  3. Compile the project:

    Open command window and cd into PGSGP direcory and run command below

    • Windows:

      gradlew.bat assembleRelease

    • Linux:

      ./gradlew assembleRelease

  4. Copy the newly created .aar file to your plugin directory:

app/build/outputs/aar/GodotPlayGamesServices.release.aar to [your godot project]/android/plugins/

How to use

First step is plugin initialization

var play_games_services
# Check if plugin was added to the project
if Engine.has_singleton("GodotPlayGamesServices"):
  play_games_services = Engine.get_singleton("GodotPlayGamesServices")
	
  # Initialize plugin by calling init method and passing to it a boolean to enable/disable displaying game pop-ups
  
  var show_popups := true 
  play_games_services.init(show_popups)
  # For enabling saved games functionality use below initialization instead
  # play_games_services.initWithSavedGames(show_popups, "SavedGamesName")
  
  # Connect callbacks (Use only those that you need)
  play_games_services.connect("_on_sign_in_success", self, "_on_sign_in_success") # account_id: String
  play_games_services.connect("_on_sign_in_failed", self, "_on_sign_in_failed") # error_code: int
  play_games_services.connect("_on_sign_out_success", self, "_on_sign_out_success") # no params
  play_games_services.connect("_on_sign_out_failed", self, "_on_sign_out_failed") # no params
  play_games_services.connect("_on_achievement_unlocked", self, "_on_achievement_unlocked") # achievement: String
  play_games_services.connect("_on_achievement_unlocking_failed", self, "_on_achievement_unlocking_failed") # achievement: String
  play_games_services.connect("_on_achievement_revealed", self, "_on_achievement_revealed") # achievement: String
  play_games_services.connect("_on_achievement_revealing_failed", self, "_on_achievement_revealing_failed") # achievement: String
  play_games_services.connect("_on_achievement_incremented", self, "_on_achievement_incremented") # achievement: String
  play_games_services.connect("_on_achievement_incrementing_failed", self, "_on_achievement_incrementing_failed") # achievement: String
  play_games_services.connect("_on_achievement_info_loaded", self, "_on_achievement_info_loaded") # achievements_json : String
  play_games_services.connect("_on_achievement_info_load_failed", self, "_on_achievement_info_load_failed")
  play_games_services.connect("_on_leaderboard_score_submitted", self, "_on_leaderboard_score_submitted") # leaderboard_id: String
  play_games_services.connect("_on_leaderboard_score_submitting_failed", self, "_on_leaderboard_score_submitting_failed") # leaderboard_id: String
  play_games_services.connect("_on_game_saved_success", self, "_on_game_saved_success") # no params
  play_games_services.connect("_on_game_saved_fail", self, "_on_game_saved_fail") # no params
  play_games_services.connect("_on_game_load_success", self, "_on_game_load_success") # data: String
  play_games_services.connect("_on_game_load_fail", self, "_on_game_load_fail") # no params
  play_games_services.connect("_on_create_new_snapshot", self, "_on_create_new_snapshot") # name: String
  play_games_services.connect("_on_player_info_loaded", self, "_on_player_info_loaded")  # json_response: String
  play_games_services.connect("_on_player_info_loading_failed", self, "_on_player_info_loading_failed")
  play_games_services.connect("_on_player_stats_loaded", self, "_on_player_stats_loaded")  # json_response: String
  play_games_services.connect("_on_player_stats_loading_failed", self, "_on_player_stats_loading_failed")

After what plugin was initialized you can use supported features

Sign-in / Sign out

Sign-in
play_games_services.signIn()

# Callbacks:
func _on_sign_in_success(account_id: String) -> void:
	pass
  
func _on_sign_in_failed(error_code: int) -> void:
	pass
Sign out
play_games_services.signOut()

# Callbacks:
func _on_sign_out_success():
	pass
  
func _on_sign_out_failed():
	pass
Check if signed in
var is_signed_in: bool = play_games_services.isSignedIn()

Achievements

Unlock Achievement
play_games_services.unlockAchievement("ACHIEVEMENT_ID")

# Callbacks:
func _on_achievement_unlocked(achievement: String):
	pass

func _on_achievement_unlocking_failed(achievement: String):
	pass
Increment Achievement
var step = 1
play_games_services.incrementAchievement("ACHIEVEMENT_ID", step)

# Callbacks:
func _on_achievement_incremented(achievement: String):
	pass

func _on_achievement_incrementing_failed(achievement: String):
	pass
Set Achievement Steps
var steps = 3
play_games_services.setAchievementSteps("ACHIEVEMENT_ID", steps)

# Callbacks:
func _on_achievement_steps_set(achievement: String):
	pass

func _on_achievement_steps_setting_failed(achievement: String):
	pass
Reveal Achievement
play_games_services.revealAchievement("ACHIEVEMENT_ID")

# Callbacks:
func _on_achievement_revealed(achievement: String):
	pass

func _on_achievement_revealing_failed(achievement: String):
	pass
Show Achievements List
play_games_services.showAchievements()
Load Achievement info
play_games_services.loadAchievementInfo(false) # forceReload

# Callbacks:
func _on_achievement_info_load_failed(event_id: String):
	pass

func _on_achievement_info_loaded(achievements_json: String):
	var achievements = parse_json(achievements_json)

	# The returned JSON contains an array of achievement info items.
	# Use the following keys to access the fields
	for a in achievements:
		a["id"] # Achievement ID
		a["name"]
		a["description"]
		a["state"] # unlocked=0, revealed=1, hidden=2 (for the current player)
		a["type"] # standard=0, incremental=1
		a["xp"] # Experience gain when unlocked

		# Steps only available for incremental achievements
		if a["type"] == 1:
			a["current_steps"] # Users current progress
			a["total_steps"] # Total steps to unlock achievement

Leaderboards

Submit leaderboard score
var score = 1234
play_games_services.submitLeaderBoardScore("LEADERBOARD_ID", score)

# Callbacks:
func _on_leaderboard_score_submitted(leaderboard_id: String):
	pass

func _on_leaderboard_score_submitting_failed(leaderboard_id: String):
	pass
Show leaderboard
play_games_services.showLeaderBoard("LEADERBOARD_ID")


play_games_services.showAllLeaderBoards()

Events

Submit event
var increment_by := 2
play_games_services.submitEvent("EVENT_ID", increment_by)

# Callbacks:
func _on_event_submitted(event_id: String):
	pass
	
func _on_event_submitted_failed(event_id: String):
	pass
Load events
# Load all events
play_games_services.loadEvents()
# Or load events by given ids
play_games_services.loadEventsById(["EVENT_ID_1", "EVENT_ID_2", ...])

# Callbacks:
# If there is at least one event, following callback will be triggered:
func _on_events_loaded(events_array):
	# Parse received string json of events using parse_json
	var available_events = parse_json(events_array)
	# Iterate through the events_list to retrieve data for specific events
	for event in available_events:
		var event_id = event["id"] # you can get event id using 'id' key
		var event_name = event["name"] # you can get event name using 'name' key
		var event_desc = event["description"] # you can get event name using 'description' key 
		var event_img = event["imgUrl"] # you can get event name using 'imgUrl' key
		var event_value = event["value"] # you can get event name using 'value' key  
	
# Triggered if there are no events:
func _on_events_empty():
	pass

# Triggered if something went wrong:
func _on_events_loading_failed():
	pass

Player Stats

var force_refresh := true # If true, this call will clear any locally cached data and attempt to fetch the latest data from the server.
play_games_services.loadPlayerStats(force_refresh)

# Callbacks:	
func _on_player_stats_loaded(stats):
	var stats_dictionary: Dictionary = parse_json(stats)
	# Using below keys you can retrieve data about a player’s in-game activity
	stats_dictionary["avg_session_length"] # Average session length
	stats_dictionary["days_last_played"] # Days since last played
	stats_dictionary["purchases"] # Number of purchases
	stats_dictionary["sessions"] # Number of sessions
	stats_dictionary["session_percentile"] # Session percentile
	stats_dictionary["spend_percentile"] # Spend percentile

func _on_player_stats_loading_failed():
	pass

Player Info

play_games_services.loadPlayerInfo()

# Callbacks:	
func _on_player_info_loaded(info):
	var info_dictionary: Dictionary = parse_json(info)
	# Using below keys you can retrieve player’s info
	info_dictionary["display_name"]
	info_dictionary["name"]
	info_dictionary["title"]
	info_dictionary["player_id"]
	info_dictionary["hi_res_image_url"]
	info_dictionary["icon_image_url"]
	info_dictionary["banner_image_landscape_url"] 
	info_dictionary["banner_image_portrait_url"]
    # Also you can get level info for the player
    var level_info_dictionary = info_dictionary["level_info"]
	level_info_dictionary["current_xp_total"]
	level_info_dictionary["last_level_up_timestamp"]
    
    var current_level_dictionary = level_info_dictionary["current_level"]
    current_level_dictionary["level_number"]
    current_level_dictionary["max_xp"]
    current_level_dictionary["min_xp"]

    var next_level_dictionary = level_info_dictionary["next_level"]
    next_level_dictionary["level_number"]
    next_level_dictionary["max_xp"]
    next_level_dictionary["min_xp"]
    

func _on_player_info_loading_failed():
	pass

Saved Games

Save game snapshot
var data_to_save: Dictionary = {
		"name": "John", 
		"age": 22,
		"height": 1.82,
		"is_gamer": true
	}
play_games_services.saveSnapshot("SNAPSHOT_NAME", to_json(data_to_save), "DESCRIPTION")

# Callbacks:
func _on_game_saved_success():
	pass
	
func _on_game_saved_fail():
	pass
Load game snapshot
play_games_services.loadSnapshot("SNAPSHOT_NAME")

# Callbacks:
func _on_game_load_success(data):
	var game_data: Dictionary = parse_json(data)
	var name = game_data["name"]
	var age = game_data["age"]
	#...
	
	
func _on_game_load_fail():
	pass
Show saved snapshots screen
var allow_add_button := true
var allow_delete_button := true
var max_saved_games_snapshots := 5
var saved_games_screen_title := "TITLE"
play_games_services.showSavedGames(saved_games_screen_title, allow_add_button, allow_delete_button, max_saved_games_snapshots)

#Godot callback	
# If user clicked on add new snapshot button on the screen with all saved snapshots, below callback will be triggered:
func _on_create_new_snapshot(name):
	var game_data_to_save: Dictionary = {
		"name": "John", 
		"age": 22,
		"height": 1.82,
		"is_gamer": true
	}
	play_games_services.save_snapshot(name, to_json(game_data_to_save), "DESCRIPTION")

Troubleshooting

Check adb logcat for debuging. To filter only Godot messages use next command: adb logcat -s godot

pgsgp's People

Contributors

anisc avatar cgisca avatar congisca avatar dala00 avatar lamelynx avatar randomshaper avatar spietika avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pgsgp's Issues

Modify snapshot

Instead of letting user save and delete snapshots, I want to save a copy of the game data every time user hits save and retrieve it in case the game is uninstalled and re-installed, I found that you can't overwrite snapshot after creating it, you need to modify snapshot. So, is there a way I can modify snapshots with this plug in? Or a way to overwrite the saved snapshot or a way to delete the old snapshot and save a new snapshot?

How to retrieve idToken on sign_in function

Hi. Thank you first for the plugin.
Im doing my first Godot project so be patient with me...:)
After the sign_in function I want to connect to Firebase or retrieve information from the Leaderboard (via google API) but for that I think I need the generated idToken ... how can I get it?
Thanks in advance.

can't find the singleton.

I can build and export with the plugin but cant find the singleton.
I did include the app_id in Strings.xml.

Sign in failed

When I try to login to google play service, I get error code 4.

Error trying to Export Project.

Platform: Linux

`Starting a Gradle Daemon (subsequent builds will be faster)

Task :clean UP-TO-DATE
Task :preBuild UP-TO-DATE
Task :preDebugBuild UP-TO-DATE
Task :compileDebugAidl NO-SOURCE
Task :checkDebugManifest
Task :generateDebugBuildConfig
Task :compileDebugRenderscript NO-SOURCE
Task :mainApkListPersistenceDebug
Task :generateDebugResValues
Task :generateDebugResources
Task :javaPreCompileDebug
Task :mergeDebugResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':mergeDebugResources'.

Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #2: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #0: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #3: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #1: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #4: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #7: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #5: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.3-5435860-linux Daemon #6: AAPT2 is not supported on 32-bit Linux, see supported systems on https://developer.android.com/studio#system-requirements-a-namerequirementsa

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 23s
7 actionable tasks: 6 executed, 1 up-to-date

Exit Code: 1`

Error 12501

Hi,
thank you for the module. I really like it. But I encountered error 12501 during sign-in. I have same error with demo application. First thing I considered was wrong google play console setup but this error seems wierd to me?

Demo project doesn't compile

When compiling the demo project, the process stops with error:
Screenshot 2020-06-15 at 21 20 39

This error is solved by adding the following lines to gradle.properties from the build (gradle) folder:

android.useAndroidX=true
android.enableJetifier=true

Since it's a requirement to work, this should be stated in the readme.md file.

Infrequent crash receiving activity result

I've gotten some crash reports like this:

java.lang.RuntimeException: 
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4461)
  at android.app.ActivityThread.handleSendResult (ActivityThread.java:4503)
  at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:49)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1839)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:201)
  at android.app.ActivityThread.main (ActivityThread.java:6864)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:547)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:873)
Caused by: kotlin.UninitializedPropertyAccessException: 
  at io.cgisca.godot.gpgs.PlayGameServicesGodot.onMainActivityResult (PlayGameServicesGodot.kt:139)
  at org.godotengine.godot.Godot.onActivityResult (Godot.java:279)
  at android.app.Activity.dispatchActivityResult (Activity.java:7598)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4454)

(This corresponds to a slightly earlier version of the PGSGP code.)

This is weird, as it looks as if my game was getting the result of the Google sign-in activity before the plugin has been initialized, so before sign-in has been requested at all. My game initializes the plugin very early (from a singleton) and doesn't perform any sign-in or any other action on PGSGP until the flow reaches certain screen.

I'm clueless about why this is happening. I'm starting to wonder if a defensive null check would be good enough...

Error 10 when enable_save_games = true

I'm constantly receiving error_code = 10 as a result of
play_games_services.init(get_instance_id(), true, true)
I have enabled Google Drive API in Google APIs Console. I see requests to Google Play Game Services there, but there are no requests to Google Drive API.

When I'm not using enable_save_games:
play_games_services.init(get_instance_id(), true, false)
user is correctly logged in.

Didn't find class "org/godotengine/godot/PlayGameServices"

Thank you for the hard work building this plug-in.

Tried several times to implement the plug-in in my app. Logcat reports singleton PlayGameServices is not found. Verified "org/godotengine/godot/PlayGameServices" is in the modules list. Compared the project settings with the Demo included in the zip and can't find any differences. I tried both the PlayGamesSvcsGP-master and the PGSGP-1.2.0 versions with the same result.

Reviewed APK class.dex and did not find PlayGameServices listed. All the other the plug-in classes ARE listed in class.dex. Only PlayGameServices is missing.

Logcat out put is below (my game package names have been obfuscated). Any suggestions?

2020-04-08 08:44:26.778 13231-13255/? E/godot: ERROR: Couldn't find singleton for class: org/godotengine/godot/PlayGameServices.
2020-04-08 08:44:26.778 13231-13255/? E/godot: At: platform/android/java_godot_lib_jni.cpp:691:_initialize_java_modules() - Condition "!singletonClass" is true. Continuing.
2020-04-08 08:44:26.781 13231-13255/? E/AndroidRuntime: FATAL EXCEPTION: GLThread 12004
Process: xxxxxxx.games.xxxx, PID: 13231
java.lang.ClassNotFoundException: Didn't find class "org/godotengine/godot/PlayGameServices" on path: DexPathList[[zip file "/data/app/xxxxxxx.games.xxxx-CxyZsnOEOvQSouq0KSVcNA==/base.apk"],nativeLibraryDirectories=[/data/app/xxxxxxx.games.xxxx-CxyZsnOEOvQSouq0KSVcNA==/lib/arm, /data/app/xxxxxxx.games.xxxx-CxyZsnOEOvQSouq0KSVcNA==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.godotengine.godot.GodotLib.setup(Native Method)
at org.godotengine.godot.Godot$2.run(Godot.java:325)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1500)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)

Can't seem to submit the Leaderboard score to PGS

  1. I am able to unlock achievements (but unlocks do don't show up in Play Console? I get the pop-up however and they show up as unlocked in the Play Games App)
  2. I am able to sign in
  3. SHA key in my build and in Cloud Console matches
  4. I set up App ID and Leaderboard ID properly. I checked everything in accordance with https://developers.google.com/games/services/android/troubleshooting#check_the_certificate_fingerprint
  5. I added my email to testers

What could I be doing wrong? Maybe I am misunderstanding how things work and scores are not supposed to show up in Web Console until you publish the game?

image

Callbacks do not work

I am getting an error in the Callbacks, in all of them. Everything works, but if I try to call a print () on some callback I get this error.

E godot   : **ERROR**: Condition "!obj" is true.
E godot   :  At: platform/android/java_godot_lib_jni.cpp:1383:Java_org_godotengine_godot_GodotLib_calldeferred() - Condition "!obj" is true.

The biggest problem is that I can't use the func _on_game_load_success (saved_game): since I only get errors.

Do you have any idea what it might be?

Problems with sign in

I'm with problems at Sign In in my game. It always ends up failing with code 4. I tried other issues solutions, but even changing the SHA1 fingerprint is not solving the problem.

What I've already done:
I'm initializing the plugin as it is shown in How to use. The Google Drive API is already installed. The SHA1 fingerprint is the same in the API, in the Play Console and Keystore. I'm also using my game Keystore for debugging since the debug.keystore has another fingerprint. Play Game Service and Play Game Management are installed too. The app_id at ids.xml is the same as in the Play Console, and I'm already using the following lines at gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

What is missing? I've tried everything I've found! D:

Can't show leaderboard

I initialized the plugin it sign in but I can't show leader-board or sign out (there is something like a beginning of pop up that come and disappear before I can see it)
am I doing something wong?
PS:This is an old game that I'm porting to godot (the SH1 and google api configuration is done correctly)

Demo script has an error

Demo script (Main.gd) has an error on line 10.
It is:
play_games_services.init(get_instance_id())
(which gives a runtime error)

When it should be:
play_games_services.init(get_instance_id(), true)

Or to be more in line with README.md:

  var show_popups := true # For example, your game can display a “Welcome back” or an “Achievements unlocked” pop-up. true for enabling it.
  play_games_services.init(get_instance_id(), show_popups)

This is not an issue more of a doubt because, I am just starting out.

Where is the Main.gd? Where you need to change to your app id? And, in this

<meta-data android:name="com.google.android.gms.games.APP_ID"
   	    android:value="@string/app_id" />

Do I need to change the APP_ID here too?
Again, I am just staring out in programming so don't know much about it.

And, on the show leaderboard how to set it into a table, will playstore have a default table
Also, on unlocking achevement that icon on top of screen with exp earned will that also be done automatically?

Everything except saved games work

Hey, I have problem setting up saved games. Signing in, achievements, leader boards - all work.

Saved games turned on in Google Play Game Services for a game (and published).
Google Drive API is enabled.

I call:
play_games_services.saveSnapshot("TEST_SNAPSHOT", data, "This is beta test saved game snapshot")

where data is a dictionary converted to json:
to_json(dict_variable)

I'm kinda stuck what to check next. Debuggin with logcat is not very helpful, because all I see is a callback with status failed (_on_game_saved_fail)

Can you help me? What else should I check?

Regards

Error 4 on attempt to Sign_in

Hey All,
So I've been trying to use this for about a week and a half now with little success. So I have initiated the plugin as described in the readme and have the script being loaded in AutoLoad. Whenever I try to sign in through it triggers the _on_sign_in_failed method with an error code of 4. This appears after a dialogue appears on Android informing me it's trying to connect to google play.

Any advice on how to sort this?

Google Drive API access

I have successfully implemented all services. The issue i am facing now is that users don't want to give access to google drive. In other words instead of explicitly asking for drive permission i want to authenticate with google sign.

Get more account data

First of all, thanks for this plugin!

I read over the official guide and when signing in a user, one can get a GoogleSignInAccount. It gives access to various information such as name, email, account_id, ...

In the plugin, it seems, I can only get access to the account_id that is passed to the _on_sign_in_success callback. Is it possible to get access to the other information as well or would this require rewriting parts of the plugin?

Thanks!

Invalid applicationId with value . Reason: No application ids specified

After literally following the README.md instructions and Google Play Services setup guide, I am still unable to do the sign in. I used the 1.2.0 version of the code of this repo and also the very last commit. I am using Godot 3.2.1

This is what I get after I do a init() and sign_in():

06-28 01:33:35.985 32276 32332 W PlayCommon: [2113] pds.a: No account for auth token provided
......
06-28 01:33:36.583 30814 30856 E PlayerAgent: Unable to load player gxxxx2538xx327090xxxx
06-28 01:33:36.588 30814 30856 W PlayerAgent: {"errors":[{"domain":"global","reason":"invalid","message":"Invalid applicationId with value . Reason: No application ids specified."}],"code":400}
....
06-28 01:33:36.604 32276 32276 W SignInActivity: onSignInFailed()...
06-28 01:33:36.604 32276 32276 W SignInActivity: Sign in failed during 8
06-28 01:33:36.604 32276 32276 W SignInActivity: ==> Returning non-OK result: 10002

I also see this in the adb logs but I don't think it is related :

15288 15409 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed
15288 15409 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@[email protected] (040408-316502805):2)
15288 15409 W Conscrypt:     at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@[email protected] (040408-316502805):0)

I don't think that my problem is related to the keystore or the SHA1 certs, as I verified it many times.

Please update the instructions

Hey,

First of all - thanks for nice plugin!
Second - please update the instructions how to use it:

  • In your demo project, you are using three android permissions, which are enabled in Export -> Android -> Permissions: Access Network State, Get Accounts and Internet. It should be mentioned in the instructions
    image
  • As it was figured out by @hlfstr here: #5 (comment)
    the callback for _on_player_is_already_connected() requires 2 parameters. So the following will work:
func _on_player_is_already_connected(status : bool, id : String) -> void:
	print("hello from _on_player_is_already_connected\nStatus: %s | ID: %s" % [status,id])
  • First argument in function
    play_games_services.show_saved_games("SNAPSHOT_NAME", allow_add_button, allow_delete_button, max_saved_games_snapshots)
    is not the SNAPSHOT_NAME, but is the title of UI screen with saved games, so for example it could be "See My Saves"
  • To avoid errors with authentication, you should advise users to firstly go through all of this page: https://developers.google.com/games/services/console/enabling

new user login crash

my everyday level 8 play store account works like a charm. no problem nothing. everyting is perfect.

but there is a wierd app crass if a user creates play account for the first time (example in the picture). user logs in and the app immediately crashes after login. i think login is successfull because if i tried to open the app after the crash, it crashes again and the app is not opening. any ideas?

Screenshot_20200909-221019

Gradle build error when plug-in is included

Followed instructions for adding android-pgs-plugin to the project, rebuilt android custom build template, attempted to android export (tried debug and release) and received gradle build error.
I have no other plug-ins in the but tried removing the two lines from the plug-in AndroidManifest.xml. Received the same build error.

Sorry the gradle output window does not allow copying so I've included a image capture.

GradleBuildError

Sign-in callbacks don't work

The module works, I sign-in, submit and retrieve leaderboard score successfully. Yet, sign-in and is_player_connected callbacks don't work. I've tried some simple print("something") statements and no output. Leaderboard submission callbacks work - I get feedback from the print statement approach.

get user's current high score

i want to get user's current high score and burst confetties if breaks it. is there way to get high score from a leaderboard in pgsgp?

leaderboards don't work

i have a simple script with a button, and leaderboard doesn't work...

var score = 10
var play_games_services

func _ready():
if Engine.has_singleton("PlayGameServices"):
play_games_services = Engine.get_singleton("PlayGameServices")
play_games_services.init(get_instance_id(), true)
play_games_services.sign_in()

func _on_leaderboardbutton_pressed():
play_games_services.submit_leaderboard_score("my_leaderboard_id", score)
play_games_services.show_leaderboard("my_leaderboard_id")

Unable to get the module to work for Godot-3.2.2.

I am using Godot-3.2.2. And I am using the latest release of the module 2.2.0.

As per the instructions given in the module I added the following lines in AndroidManifest.xml file.

<meta-data 
     android:name="com.google.android.gms.games.APP_ID"
     android:value="@string/app_id" />

Then created Strings.xml file and added the following code inside it.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_id">745298242451</string>
</resources>

I created values folder inside my project folder and placed Strings.xml inside the values folder: res->values->Strings.xml.
But when I export I get the following error:
https://photos.app.goo.gl/ffmhCopsc7zHZHN28
error_leaderboard_1
Most probably I am doing something wrong. So if I can get help, it would be great.
Thanks for your time.

Couldn't find singleton for class in logcat

I have added org/godotengine/godot/PlayGameServices into Modules but I will get this error.
Any help?
Thank you!

02-09 13:20:28.106  7968  8047 I godot   : Loading Android module: org/godotengine/godot/PlayGameServices
02-09 13:20:28.106  7968  8047 E godot   : **ERROR**: Couldn't find singleton for class: org/godotengine/godot/PlayGameServices.
02-09 13:20:28.106  7968  8047 E godot   :    At: platform/android/java_godot_lib_jni.cpp:691:_initialize_java_modules() - Condition "!singletonClass" is true. Continuing.

Customize Google Drive Apps name

Is it possible to customize the name that gets registered in Google Drive for the apps using this module?
I'm getting help-luigi-8677927, which is a mixture of my app's name and id. But I would like it to look like the other apps, who get proper names.

GoogleDriveAppsScreenshot

This change is not only cosmetic since it raises the app credibility towards users.
Any change to allow for this kind of customization?

Stuck forever after tapping on account to sign in if using initWithSavedGames instead of just init

20210201_193002
Godot 3.2.3
Android 10

After tapping on an account to sign in if using initWithSavedGames instead of just init, the next popup appears and just keeps loading forever.

"Saved Games" is enabled in the Google Play Console and these are all added:

  • Google Play Game Services
  • Google Play Game Management
  • Google Drive API

if init is used instead, it signs in almost perfectly except the account_id is always null in _on_sign_in_success.

[CAUSED BY DEPRECATED API] Only works with default configuration and Class not found when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration

Godot 3.2.3
Android 10

This happens everytime when signing in if not using default configuration.

02-03 12:17:29.120  1494  3782 E Parcel  : Class not found when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
02-03 12:17:29.120  1494  3782 E Parcel  : java.lang.ClassNotFoundException: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
02-03 12:17:29.120  1494  3782 E Parcel  : 	at java.lang.Class.classForName(Native Method)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at java.lang.Class.forName(Class.java:454)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.Parcel.readParcelableCreator(Parcel.java:3031)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.Parcel.readParcelable(Parcel.java:2981)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.Parcel.readValue(Parcel.java:2883)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.Parcel.readArrayMapInternal(Parcel.java:3261)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.BaseBundle.unparcel(BaseBundle.java:236)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.BaseBundle.getString(BaseBundle.java:1160)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.content.Intent.getStringExtra(Intent.java:8548)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:765)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:676)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1778)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:607)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1615)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1512)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at com.android.server.wm.ActivityTaskManagerService.startActivity(ActivityTaskManagerService.java:1466)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.app.IActivityTaskManager$Stub.onTransact(IActivityTaskManager.java:1655)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.Binder.execTransactInternal(Binder.java:1021)
02-03 12:17:29.120  1494  3782 E Parcel  : 	at android.os.Binder.execTransact(Binder.java:994)
02-03 12:17:29.120  1494  3782 E Parcel  : Caused by: java.lang.ClassNotFoundException: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
02-03 12:17:29.120  1494  3782 E Parcel  : 	... 20 more

Problem with incremental Achievements

I have several achievements defined in my game. The easiest requires 10 steps.
I can increment all of them, yet, I can't get past the 9th step in the 10-step incremental achievement.

Is there any catch how to program it? I've found that if I go for an increment above the defined steps, it increments nothing, so my code is:

# Incrementar Achievements
func achievements_increment(achievement, incremento):
	
	if play_games_services:
		
		for _x in range(incremento):
			play_games_services.increment_achievement(achievement, 1)
	
	pass

This takes me to 9, but not to 10 and no unlock.
Does anyone have this working?

The callback for increment_achievements gives sucess eveytime. Adb logcat -g godot shows nothing.

Running the google play management API (https://www.googleapis.com/games/v1/players/{playerId}/achievements) shows all the achievements being incremented normally. This one stops incrementing at 9.

Is this a bug? Is there something I'm missing?

Problem with achievements

Hi, how are you? I am having some problems with the achievements of a published game. The problem is that achievements are unlocking normally, all callbacks return positive, pop ups appear to the user but the achievement disappears after a while. It is as if Google did not register, did not accept.

Do you have any knowledge about this? Something I can help me with?

I already reviewed everything but in the API panel, I still receive 100% error in the requests
games.achievements.unlock
games.applications.played
games.achievements.updateMultiple

I don't know if it is any with the module or another reason: /

Ambiguity about is_player_connected()

It is not clear what is the role of the function is_player_connected(), I assumed it is used to check if the player is already connected or not but It always returns a null.

There must be a way to check if the sign-in to Google Play Games Services was successful and if the player is connected, I tried the _on_player_is_already_connected but it is never called.

Problem with snapshots not being saved.

Hi. I have a problem where a snapshot I'm saving isn't being saved. I can load a saved game. When I save the game I get the success callback. But when I restart my game and load the save again the data I just saved isn't what is loaded. Does anyone know what might cause this?

save_snapshot not working

I'm using release 1.2.0. When I call save_snapshot I get two times the _on_game_saved_fail callback (yes, 2 times for each call). Show_saved_games, however, works - I get a window showing no saves. Sign_in is successful, I get the _on_sign_in_success callback with the account_id and I also get the welcome notification window in the game.

I've checked the following points:

  • I'm calling play_games_services.init with the enable_save_games = true
  • I have the correct APIs connected to the game (as picture)

image

  • I have all the APKs authorised (the debug, production and the Google signed APK)
    image

  • I have no errors on the API's console (as picture)
    image

  • I've made the code as simple as possible for testing purposes (as shown; nome_snap is "Snap1")

func save_game(nome_snap) -> void:
		
	if play_games_services:
		play_games_services.save_snapshot(nome_snap, "1", "Gamesave")

The call of save_game is very simple, just:
GPlay.save_game("Snap1")
(I'm using an autoload for the play_games_services but using a regular scene or just script gives the same result)

Every time I call the method, I get 2 times "Game saved fail", in the following callback:

func _on_game_saved_fail():
	print("Game saved fail")

The log doesn't provide any useful information:

adb logcat -s godot
--------- beginning of crash
--------- beginning of system
--------- beginning of main
06-09 19:25:15.868 25829 25886 I godot   : Loading Android module: org/godotengine/godot/GodotAdMob
06-09 19:25:15.876 25829 25886 I godot   : Loading Android module: org/godotengine/godot/PlayGameServices
06-09 19:25:16.005 25829 25886 I godot   : Godot Engine v3.2.1.stable.official - https://godotengine.org
06-09 19:25:16.018 25829 25886 I godot   : OpenGL ES 2.0 Renderer: Adreno (TM) 508
06-09 19:25:16.318 25829 25886 I godot   :  
06-09 19:25:17.401 25829 25886 D godot   : AdMob: init with content rating options
06-09 19:25:19.138 25829 25886 I godot   : Success
06-09 19:25:19.138 25829 25886 I godot   : 103236622368481239XXX
06-09 19:25:22.027 25829 25829 W godot   : AdMob: onAdLoaded
06-09 19:25:44.444 25829 25886 I godot   : Game saved fail
06-09 19:25:44.445 25829 25886 I godot   : Game saved fail

I'm out of ideas here. I think I'm not missing anything.
Is this a bug?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.