You copied the Doc URL to your clipboard.

Using the OpenGL ES, EGL, and OpenCL Interceptor in a Target Application

Using the interceptor in an Android application requires two steps:
  1. Packaging the interceptor into the application
  2. Enabling the interceptor
Step 1 is the same for all applications, but step 2 depends on whether your application uses Java, C++, or both.

Packaging the Interceptor

We need to add the GA unrooted library folder to the list of locations the Android build system looks for native libraries. This will ensure GA is included in the resulting APK.

To do this, add the following code to your modules build.gradle file:
android {
    sourceSets {
        main {
            jniLibs.srcDirs += ['[GA installation directory]/target/android/arm/unrooted/']
        }
    }
}
Replacing [GA installation directory] with the real path.

Enabling the Interceptor with a C/C++ Only Application

Native applications on Android are unable to load a library that depends on non-system libraries. Therefore, linking your native library against GA will cause the application to fail at runtime as it won't be able to load GA even if it's included in the APK.

The solution to this is to add a very small Java component to your application. Create a new Activity class which extends android.app.NativeActivity.

Make sure this new Activity is referenced in your AndroidManifest.xml as the android:name attribute of the activity element. Also check that the android:hasCode attribute of the application element is set to true, otherwise the Java files will not be included in the APK.

Now you can follow the instructions below for mixed Java and C/C++ applications.

Note: There is no need to link your native library to GA.

Enabling the Interceptor with a Java Only or a Mixed Java and C/C++ Application

Now we need to make sure your application will actually load GA. Add the following code to the beginning of your project's main Activity class:
static
{
    try
    {
        System.loadLibrary("AGA");
    }
    catch (UnsatisfiedLinkError e)
    {
        // Feel free to remove this log message.
        Log.e("[ GA ]", "GA not loaded: " + e.getMessage());
        Log.d("[ GA ]", Log.getStackTraceString(e));
    }
}

Recompile the application and install it on your Android device.

ABIs

The interceptor for unrooted devices is only available for the armeabi-v7a and arm64-v8a ABIs.

To ensure your build works as expected you must make sure you specify a appropriate value for abiFilters in your modules build.gradle. To target both of the Armv7 and Armv8 targets, your modules build.gradle should contain:
android {
    defaultConfig {
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a'
        }
    }
}

See the ABI Management documentation for more information about Android ABIs.

Was this page helpful? Yes No