Face Capture – Android

Estimated reading: 3 minutes 13 views

#Step 1: Configure Your settings.gradle File

This file tells Gradle where to look for your private package. Open the settings.gradle file in the root of your project and ensure it looks like this:

// settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()

        // Add the private GitHub repository for Aware
        maven {
            url = uri("https://maven.pkg.github.com/Aware-Distribution/Android-Face-Capture")
            credentials {
                if (settings.hasProperty('gpr.user')) {
                    username = settings['gpr.user']
                }
                if (settings.hasProperty('gpr.key')) {
                    password = settings['gpr.key']
                }
            }
        }
    }
}

rootProject.name = "My Application"
include ':app'

#Step 2: Configure Your gradle.properties File

gpr.user=Aware-Distribution
gpr.key={{KEY-HERE}}

#Step 3: Add the Dependency to app/build.gradle

Now, open the build.gradle file located inside your app module. Add the implementation line for the face-capturelibrary inside the dependencies block.

// app/build.gradle

// ... (plugins and android blocks) ...

dependencies {
    // Other dependencies like core-ktx, appcompat, etc.
    // ...
    // Add this line for the face-capture library
    implementation 'com.aware-distribution:face-capture:2.5.1'
}

#Step 3: Sync Your Project

In Android Studio, a bar will appear at the top of the editor prompting you to sync. Click "Sync Now". Gradle will now use your credentials to find and download the library from your private repository.

#How to Use the Library in Your Code

Once the project syncs successfully, you can use the library's classes in both Kotlin and Java.

#In a Kotlin Project (MainActivity.kt)

You can import and use the classes from the library just like any other dependency.

// app/src/main/java/com/your/package/name/MainActivity.kt

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
// Example: Import a class from the face-capture library
import com.aware.facecapture.FaceCaptureJNI

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Example: You can now create an instance of a library class
        // val faceCapture = FaceCaptureJNI()
    }
}

#In a Java Project (MainActivity.java)

The process is the same for Java—simply import the required classes and use them.

// app/src/main/java/com/your/package/name/MainActivity.java

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
// Example: Import a class from the face-capture library
import com.aware.facecapture.FaceCaptureJNI;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Example: You can now create an instance of a library class
        // FaceCaptureJNI faceCapture = new FaceCaptureJNI();
    }
}
CONTENTS