• Hello
Search Results for

    Show / Hide Table of Contents

    Android - App Libraries - Monitor (Pro)

    Your built code lives in library files inside the Android app. Editing that code is hard. A common cheat adds a new library to the app instead.

    This monitor lists the libraries in the app. The Android package tampering detector rejects the ones that do not belong.

    This monitor needs the Pro version.

    Walkthrough: Protecting an Android build.

    Do you need to add it?

    Most of the time, no. The Android Package Cheating Detector prefab already includes this monitor. That prefab is part of the predefined Anti-Cheat-Monitor prefab.

    Add the AndroidPackageLibraryMonitor component (namespace GUPS.AntiCheat.Monitor.Android) by hand only if you build your own setup, or if you only want the raw reading. Put it on the same GameObject as its detector. The detector looks for it there.

    Add the AndroidPackageLibraryMonitor component.

    What it reports

    The monitor reads the libraries once, when it starts. It then sends one AndroidLibraryStatus:

    public struct AndroidLibraryStatus : IAndroidStatus
    {
        // True if the libraries could not be read.
        public bool FailedToRetrieveData { get; }
    
        // The file names of the libraries packed in the running app.
        public List<string> Libraries { get; }
    }
    
    • FailedToRetrieveData: The libraries could not be read. The list is not valid.
    • Libraries: The library file names packed in the app, for example libunity.so.

    Settings

    The monitor has one field in the Inspector:

    • Is Active (isActive, bool, default true): Turns the monitor on or off.

    The allow list and the block list are set in the project settings. The detector uses those lists. Open Edit > Project Settings > GuardingPearSoftware > AntiCheat, select the Android tab and go to Android - App Library - Settings.

    Library allow and block lists.

    • White-/Blacklist libraries: Off by default. Turn it on to use this check.
    • Whitelisted libraries: The libraries that belong to your app.
    • Blacklisted libraries: Libraries that must not be in your app.
    Tip

    To find the names, open your built app in a zip tool. Look in the library folder, for example lib\armeabi-v7a\. Enter each file name with its extension.

    Libraries inside a built Android app.

    Good to know

    • Not in the Editor: The monitor only reads the libraries on an Android device. In the Editor it sends nothing and logs a warning.
    • Development builds: Verify development builds is off by default. While it is off, the detector does not judge development builds. Turn it on while you test.

    Turn on Verify development builds to also check development builds.

    Platforms and requirements

    Android only. Android 4.4 (API level 19) or newer.

    The Android plugin com.gups.anticheat ships with the package in Assets/GUPS/AntiCheat/Plugins/Android/.

    Read it in code

    You can listen to the monitor yourself. Subscribe returns an IDisposable. Dispose it when you want to stop.

    using System;
    using GUPS.AntiCheat.Core.Watch;
    using GUPS.AntiCheat.Monitor.Android;
    using UnityEngine;
    
    public class AndroidLibraryStatusLogger : MonoBehaviour, IObserver<IWatchedSubject>
    {
        private void Start()
        {
            var monitor = GetComponentInChildren<AndroidPackageLibraryMonitor>();
            monitor.Subscribe(this);
        }
    
        public void OnNext(IWatchedSubject subject)
        {
            if (subject is AndroidLibraryStatus status)
            {
                if (status.FailedToRetrieveData)
                {
                    Debug.LogWarning("Could not read the app libraries.");
                    return;
                }
    
                Debug.Log($"Found {status.Libraries.Count} libraries.");
            }
        }
    
        public void OnError(Exception error) { }
        public void OnCompleted() { }
    }
    

    Detect a library that does not belong

    To compare the list with your allow and block lists, use the Android package tampering detector.


    Back to the Monitor overview.

    In This Article
    Back to top GuardingPearSoftware documentation