> For the complete documentation index, see [llms.txt](https://andia.gitbook.io/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andia.gitbook.io/api/android-sdk.md).

# Android SDK

## Requirements

* **Android SDK 21 (LOLLIPOP) or higher and includes Google Play Services**
* **Latest Android Studio**&#x20;

## Download & Install the Library <a href="#download-and-install-the-sdk" id="download-and-install-the-sdk"></a>

Download the AndiaAndroid zip from this [Github link ](https://github.com/josebetomex/android_biometric_authentication/releases)

Unzip the Folder AndiaAndroid.zip

## Import the file andia-selfie.aar into your project in Android Studio <a href="#copy-the-file-selfie-framework-into-your-ios-project-in-xcode" id="copy-the-file-selfie-framework-into-your-ios-project-in-xcode"></a>

Click **File > New > New Module**.

![](/files/-L_8jUbSP8pKaFP1bBGA)

Enter the location of the library then click **Finish**.

![](/files/-L_8kbzbP3O3r73PXapr)

Right click on the new app folder and select **Open Module Settings**

![](/files/-L_8oiEOkNN8NwEKu5xV)

In Dependencies, select **Add Module Dependency**, and then select the imported **Selfie Module**.

![](/files/-LqH1uPp1G8E-XqWDlhZ)

## Add Google Play Services

In your **build.gradle** file (project level) add google Services :

```javascript
buildscript {
   repositories {
        google()
        jcenter()
     }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'  //<---  ADD HERE 
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
.......
```

## Add Dependencies

In your **build.gradle** file (App level) add  the following lines

```groovy
implementation 'com.google.firebase:firebase-ml-vision:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation  'com.loopj.android:android-async-http:1.4.9'
implementation project(':andia-debug')
```

```javascript
//###########      Example App build.gradle .  
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.beto.andiaexample"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':andia-debug')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.firebase:firebase-ml-vision:16.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation  'com.loopj.android:android-async-http:1.4.9'
    implementation project(':andia-debug')
}

```

## Update the Manifest file

Add the following settings to the manifest.xml file

```markup
    <uses-feature android:name="android.hardware.camera" android:required="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <meta-data  android:name="com.google.firebase.ml.vision.DEPENDENCIES" android:value="face" />
```

## Using the Library

Import the classes in your Activity

```java
import io.andia.example.ResultOnboarding;
import io.andia.example.SelfieValidator;
import io.andia.example.SelfieCallback;
import io.andia.example.ResultValidation;
```

In your Main Activity implement SelfieCallback

```java
public class MainActivity extends AppCompatActivity implements SelfieCallback {
     
     //activity Code
     
     // ...
     
    //Callback for OnBoarding.
    @Override
    public void resultOnBoarding(ResultOnboarding result) {
        Log.d("ANDIA", result.getMessage());

    }

    //Callback for Validation.
    @Override
    public void resultValidation(ResultValidation result){
        Log.d("ANDIA", result.getMessage());
    }
     
}
```

Call the OnBoarding Method.

```java
onboardingButton = (Button) findViewById(R.id.buttonOnboard);
        onboardingButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
            
                SelfieValidator validator = new SelfieValidator();
                validator.onboarding("API_KEY", MainActivity.this);
                
            }
        });
```

Call the Validation Method

```java
validateButton = (Button) findViewById(R.id.buttonValidate);
validateButton.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View arg0) {
        SelfieValidator validator = new SelfieValidator();
        validator.validation("API_KEY", "userid", MainActivity.this);
    }
});
```

### Download Example�

Example Project in this [Github Link](https://github.com/josebetomex/android_biometric_authentication)
