• 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 instead.

    Walkthrough: Protecting an Android build.

    This monitor lists the libraries in the app so you can reject ones that do not belong.

    Monitor

    AndroidPackageLibraryMonitor (namespace GUPS.AntiCheat.Monitor.Android) reads the files in the app's library folder, for example {APK}\lib\armeabi-v7a\. It then sends an AndroidLibraryStatus.

    Status

    The monitor sends an AndroidLibraryStatus:

    public struct AndroidLibraryStatus : IAndroidStatus
    {
        // True if the libraries could not be retrieved (e.g. a JNI failure).
        public bool FailedToRetrieveData { get; }
    
        // The names of the native libraries bundled in the running app (APK/AAB).
        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.

    Lifecycle and timing

    The monitor reads the libraries once, when it starts. It then sends one AndroidLibraryStatus. If the read fails, it still sends a status, with FailedToRetrieveData set to true.

    Configuration

    This monitor has no Inspector fields. The allow list and block list are set in Project Settings. The detector uses those lists. Open Edit > Project Settings > GuardingPearSoftware > AntiCheat and go to Android - App Library - Settings.

    Library allow and block lists.

    To find the names, open the 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.

    Development builds

    Verify development builds is off by default. While it is off, the check skips development builds and the Editor. Turn it on while you test.

    Turn on Verify development builds to also check development builds and the Editor.

    Supported platforms

    Android only.

    Requirements

    Android 4.4 (API level 19) or newer.

    How to use

    Add AndroidPackageLibraryMonitor as a child of the AntiCheat-Monitor. Pair it with AndroidPackageTamperingDetector.

    Add the component

    Add AndroidPackageLibraryMonitor from GUPS.AntiCheat.Monitor.Android. A child of the monitor is the best place.

    Add the AndroidPackageLibraryMonitor component.

    Read the status in code

    You can also listen 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.

    In This Article
    Back to top GuardingPearSoftware documentation