# 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**.

![](https://4135326984-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWYRFhPFNj-4U-FyHVP%2F-L_8Wr0-isq1JLu6uAkm%2F-L_8jUbSP8pKaFP1bBGA%2FScreen%20Shot%202019-03-04%20at%2011.10.29.png?alt=media\&token=c877b6a5-eaac-4afe-b96e-2f24a160a047)

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

![](https://4135326984-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWYRFhPFNj-4U-FyHVP%2F-L_8Wr0-isq1JLu6uAkm%2F-L_8kbzbP3O3r73PXapr%2FScreen%20Shot%202019-03-04%20at%2011.10.50.png?alt=media\&token=36f85f2b-bedd-4ddc-bc27-210a62f415d0)

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

![](https://4135326984-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWYRFhPFNj-4U-FyHVP%2F-L_8Wr0-isq1JLu6uAkm%2F-L_8oiEOkNN8NwEKu5xV%2FScreen%20Shot%202019-03-04%20at%2011.43.17.png?alt=media\&token=4328ed47-8d0c-40f6-b699-08ba87ebc7d5)

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

![](https://4135326984-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWYRFhPFNj-4U-FyHVP%2F-LqH0JZjQBshYXh7MnaZ%2F-LqH1uPp1G8E-XqWDlhZ%2Fimage.png?alt=media\&token=2de65cd4-f596-4223-9762-43f5df652218)

## 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andia.gitbook.io/api/android-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
