Android: upgraded everything! (Google Play Services, OpenAL, AdMob, API level, Gradle…)

Posted on

Game Services Demo in Castle Game Engine
Game Services Demo in Castle Game Engine

First of all, you can actually test our Android integration (and many upgrades described below) by trying out these test applications (APK) on your Android device.

We are also releasing these demo applications (and more!) on Google Play, to give everyone a really easy way to test CGE on Android. More about it when we’ll upload and publish everything 🙂

Now, the details about the Android changes done lately:

  1. Google Play Games integration code was upgraded to use the latest (v1) API. Building of Android packages doesn’t make any “deprecation” warnings anymore.

    Everything is supported and tested:

    • Signing-in,
    • achievements,
    • leaderboards,
    • savegames.

    Actually a further upgrade to the sign-in logic is coming, through Google Play Games v2. They are almost equal (in code too) to v1, except the sign-in is even more automatic.

  2. Example examples/mobile/game_services presents how to use Google Play Games. It show using automatic sign-in, achievements, leaderboards, savegames.

    The usage from Pascal comes down to the TGameService class.

  3. Updated OpenAL (sound playback) service on Android (thank you to Andrzej Kilijański!).

    This fixes issue with stuttering sound playback on new Android devices.

    Note that OpenAL is used automatically when you build your game for Android, and you use sound. Declaring dependency on sound or having any *.wav, *.ogg file in data automatically adds this Android service.

    Changes related to new OpenAL:

    • We use latest OpenAL C++ code from OpenAL Soft (tag 1.23.1).

    • We use CMake compilation following Android guidelines.

      The manual compilation process is described in details on Andrzej blog, but you don’t need to do it yourself. We added C++ code and CMake configuration to the Android project, and it will be “compiled correctly and automatically” when you build Android application using CGE. Just build Android application as always, using CGE build tool or editor, and it will just create APK or AAB for you.

      Note: The C++ source code size is just 3.9 MB (previous precompiled libs were 1.3MB). So size isn’t any problem to distribute, it’s literally just 2.6 MB more.

    • A nice internal side-effect is also that updating to the latest OpenAL will be easier. We don’t host precompiled OpenAL libraries anymore, https://github.com/castle-engine/android-openal is now archived and useless. We will only need to update OpenAL sources in the CGE service, and Android compilation process (Gradle) will take care of building everything for all relevant platforms.

    • New OpenAL uses underneath Oboe.

    • Note: we use shared libraries following Google recommendation.

  4. Updated Google AdMob on Android to use latest API – 22.1.0. (Thanks to Andrzej Kilijański!).

    If you’re interested in using AdMob in CGE, see admob service docs. Note that Pascal API for mobile ads didn’t change, you don’t need to adjust anything, just upgrade to the latest CGE.

    Older API was deprecated by Google.

  5. Increased Android compilation SDK level to 33.

    This will be needed soon for new Google Play uploads.

  6. Increased also Android minimum SDK level to 21. This means CGE supports only Android >= 5.0.

    AdMob requires Android API level 19.

    Oboe 1.7.0 requires Android API level 21.

    Realistically, testing also requires us to bump Android versions — we cannot test on very ancient Android devices, as we don’t have them anymore 🙂

  7. Various pieces of the Android build process updated, to use latest Android Gradle plugin (8.1.0), Gradle (8.0), CMake, AndroidX approaches, and generally follow latest recommended practices.

  8. Documentation updates:

  9. The “base” Android project type was removed, as it was only a maintenance burden at this point.

    For all practical purposes, you need to use “integrated”, that has a bit of Java code and enables integration with a number of services (many in Java, some in native code — like OpenAL). And “integrated” was a default since a long time.

    Maintaining the “base” project wasn’t really useful anymore, since we didn’t recommend to ever use it.

  10. Android services heyzap and google_analytics have been removed. The ecosystem moves fast, and some things just aren’t available anymore.

    Heyzap has been acquired by Fyber (which was later acquired by Digital Turbine). Maybe Digital Turbine offers a similar SDK, it remains to be tested.

    Google Analytics has been deprecated by Google and actually crashes on new Android devices. Google recommends migrating to their Firebase Analytics, we may add support for it in future CGE versions. Currently the best mobile analytics, integrated with CGE on both Android and iOS, are provided by game_analytics service.

Start the discussion at Castle Game Engine Forum