5 releases

0.2.3 Sep 12, 2022
0.2.2 Aug 30, 2022
0.2.1 Aug 25, 2022
0.2.0 Aug 16, 2022
0.1.9 Aug 10, 2022

#807 in Game dev

MIT/Apache

170KB
2.5K SLoC

Rust 1.5K SLoC // 0.0% comments Kotlin 861 SLoC // 0.3% comments

Crossbow Admob Plugin

Crate Info Documentation MIT/Apache 2.0 GitHub Stars

About

This project is a Crossbow Plugin for Google Play Games Services written in Rust and Kotlin.

Supported features:

Feature Available
Sign-in/Sign out
Achievements 🆗
Leaderboards 🆗
Events 🆗
Player Stats 🆗
Player Info 🆗
Saved Games 🆗

✅ = Works and tested — 🆗 = Works but may contain bugs — 🛠 = Under development — 📝 = Planned - ❌ = Not working - ❗ = Not planned to be implemented

Installation

Just add Rust dependencies like this:

[dependencies]
crossbow = "0.2.3"
[target.'cfg(target_os = "android")'.dependencies]
play-games-services = "0.2.3"

And finally, add this to your Crossbow Android configuration:

[package.metadata.android]
plugins_remote = ["com.crossbow.play_games_services:play_games_services:0.2.3"]

Getting started

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

Setting up AndroidManifest resources

Create you resources directory and import it by adding the following in your Cargo.toml:

[package.metadata.android]
resources = ["./res/android"]

Then create file ./res/android/values/games-ids.xml in your resources directory with the following content:

<?xml version="1.0" encoding="utf-8"?>
<!--Google Play game services IDs. Save this file as res/values/games-ids.xml in your project.-->
<resources>
    <!--app_id-->
    <string name="app_id" translatable="false">ADD_YOUR_APP_ID</string>
</resources>

Important: You need to replace ADD_YOUR_APP_ID with your app ID. Read official instructions to learn more.

Next, specify the package and meta_data for the Application's AndroidManifest.xml in your Cargo.toml:

[package.metadata.android.manifest]
package = "com.crossbow.play_games"
[[package.metadata.android.manifest.application.meta_data]]
name = "com.google.android.gms.games.APP_ID"
value = "@string/app_id"
[[package.metadata.android.manifest.application.meta_data]]
name = "com.google.android.gms.version"
value = "@integer/google_play_services_version"

That's it, now you can start using Play Games Services!

Usage

First step is plugin initialization. In your rust project, you will need to initialize Crossbow instance and then get Android plugin:

#![cfg(target_os = "android")]

use crossbow::android::*;
let crossbow = CrossbowInstance::new();
let play_games: play_games_services::PlayGamesServicesPlugin = crossbow.get_plugin()?;
// Initialize Google Play Games Services
play_games.init(true)?;

After plugin initialization you can use supported features. For example to SignIn user you can use:

play_games.sign_in()?;

To read signals:

if let Ok(signal) = play_games.get_receiver().recv().await {
    println!("Signal: {:?}", signal);
}

Complete documentation you can find here.

Troubleshooting

  1. If you use Android Emulator - make sure that you use one that supports Google Play Games Services. See similar StackOverflow question.
  2. If you keep getting Error 12501 - make sure that fingerprint, package, and resources are configured correctly. See similar StackOverflow question.
  3. If you keep getting Error 4 - make sure that you sign your Application with correct Play Store key.

Thanks and inspiration

This Plugin was initially adapted and inspired by godot-pgsgp.

Dependencies

~0.4–0.8MB
~19K SLoC