Installing AHL on Android
Installing the Appium Helper Library (AHL) on an Android applications has the following steps:
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:
The
settings.gradle
file, if Gradle is set to prefer project repositoriesFor more information on these options, see Gradle Documentation for Declaring Repositories.
After you add the Artifactory repository, you need to add the dependency to your project.
Adding the Artifactory repository using build.gradle
Open your app project's
build.gradle
file, typically located in/app/build.gradle
.Add the Applitools Artifactory repository declaration to the
repositories
node:repositories {
maven {
url 'https://applitools.jfrog.io/artifactory/Android/'
}
}Continue with Adding the AHL dependency
Adding the Artifactory repository using settings.gradle
Open the
settings.gradle
file, typically located in the root directory of your project.Add the Applitools Artifactory repository declaration to the
dependencyResolutionManagement
>repositories
node:dependencyResolutionManagement {
repositories {
maven {
url 'https://applitools.jfrog.io/artifactory/Android/'
}
}
}Continue with Adding the AHL dependency
Adding the AHL dependency
Open your app project's
build.gradle
file, typically located in/app/build.gradle
.Add the AHL dependency declaration to the
dependencies
node:dependencies {
implementation 'com.applitools:eyes-appium-helper-androidx:latest.release@aar'
}Sync your Gradle project
Local dependency
You can add the AHL as a local dependency using one of the following methods:
Using Android Studio
Download the latest build of the Android Library file (
.aar
):https://applitools.jfrog.io/artifactory/Android/com/applitools/eyes-appium-helper-androidx/
Copy the AHL file into a library folder inside your Android project. For example,
/lib
.In Android Studio, open Project Structure > Dependencies.
Choose the main app module, then click + under Declared Dependencies.
Select JAR/AAR Dependency.
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
Choose implementation from the dropdown list, then click OK.
Click OK to close the Project Structure dialog box.
Using Gradle
Download the latest build of the Android Library file (
.aar
):
https://applitools.jfrog.io/artifactory/Android/com/applitools/eyes-appium-helper-androidx/Copy the AHL file into a library folder inside of your Android project. For example,
/lib
Open your app project's
build.gradle
file, typically located in/app/build.gradle
.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"))
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:
Using the Application class (Recommended)
- Java
- Kotlin
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);
}
}
import android.app.Application
import com.applitools.appium.helper.androidx.EyesAppiumHelper
class App : Application() {
override fun onCreate() {
super.onCreate()
EyesAppiumHelper.initialize(this)
}
}
Main activity
Integrate the following to the all main activities in the application.
- Java
- Kotlin
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());
}
}
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.applitools.appium.helper.androidx.EyesAppiumHelper
class MainActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
EyesAppiumHelper.initialize(this.application)
}
}