Skip to main content

Installing AHL on Android

Installing the Appium Helper Library (AHL) on an Android applications has the following steps:

  1. Add the AHL dependency to your Android project
  2. Instantiate the AHL in your onCreate app code

Add the AHL dependency to your Android project

Add the AHL to your Android app using one of the following:

Gradle Maven dependency

To import the AHL dependency in Gradle using Maven, add the Applitools Artifactory repository in your Gradle repository using one of the following:

After you add the Artifactory repository, you need to add the dependency to your project.

Adding the Artifactory repository using build.gradle

  1. Open your app project's build.gradle file, typically located in /app/build.gradle.

  2. Add the Applitools Artifactory repository declaration to the repositories node:

    repositories {
    maven {
    url 'https://applitools.jfrog.io/artifactory/Android/'
    }
    }
  3. Continue with Adding the AHL dependency

Adding the Artifactory repository using settings.gradle

  1. Open the settings.gradle file, typically located in the root directory of your project.

  2. Add the Applitools Artifactory repository declaration to the dependencyResolutionManagement > repositories node:

    dependencyResolutionManagement {
    repositories {
    maven {
    url 'https://applitools.jfrog.io/artifactory/Android/'
    }
    }
    }
  3. Continue with Adding the AHL dependency

Adding the AHL dependency

  1. Open your app project's build.gradle file, typically located in /app/build.gradle.

  2. Add the AHL dependency declaration to the dependencies node:

     dependencies {
    implementation 'com.applitools:eyes-appium-helper-androidx:latest.release@aar'
    }
  3. Sync your Gradle project

Local dependency

You can add the AHL as a local dependency using one of the following methods:

Using Android Studio

  1. Download the latest build of the Android Library file (.aar):

    https://applitools.jfrog.io/artifactory/Android/com/applitools/eyes-appium-helper-androidx/

  2. Copy the AHL file into a library folder inside your Android project. For example, /lib.

  3. In Android Studio, open Project Structure > Dependencies.

  4. Choose the main app module, then click + under Declared Dependencies.

  5. Select JAR/AAR Dependency.

  6. Provide the path to the AHL file. Note that this path is relative to /app, so you may need to traverse directories to refer to your library folder, for example:

    ../lib/eyes-appium-helper-androidx-1.8.7.aar

  7. Choose implementation from the dropdown list, then click OK.

    Project Structure Dialog

  8. Click OK to close the Project Structure dialog box.

Using Gradle

  1. Download the latest build of the Android Library file (.aar):
    https://applitools.jfrog.io/artifactory/Android/com/applitools/eyes-appium-helper-androidx/

  2. Copy the AHL file into a library folder inside of your Android project. For example, /lib

  3. Open your app project's build.gradle file, typically located in /app/build.gradle.

  4. Add the AHL dependency declaration to the dependencies node:

     dependencies {
    implementation (files("[pathtolib]/eyes-appium-helper-androidx-[version].aar"))
    }

    where pathtolib is the relative path to your libraries folder. Note that this path is relative to /app, so you may need to traverse directories, for example: implementation (files("../lib/eyes-appium-helper-androidx-1.8.7.aar"))

  5. Sync your Gradle project

Note: The AHL for Android is updated periodically. When updates occur, you will need to repeat this process.

Instantiating the AHL

Integrate the following code to onCreate using one of the following examples based on your launcher activity:

import android.app.Application;  
import com.applitools.appium.helper.androidx.EyesAppiumHelper;

public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
EyesAppiumHelper.initialize(this);
}
}

Main activity

Integrate the following to the all main activities in the application.

import androidx.appcompat.app.AppCompatActivity;  
import com.applitools.appium.helper.androidx.EyesAppiumHelper;

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EyesAppiumHelper.initialize(this.getApplication());
}
}