|The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.|
To create object-based Android tests, your tested application must be instrumented. TestComplete does it automatically when running Android applications from the Tested Applications collection.
This topic explains an alternative approach – how to instrument Android applications with Android Studio.
Do not submit instrumented applications to the Google Play. Instrumented applications use private APIs and will be rejected. Create a separate build configuration for test builds.
The instructions below assume that Android Studio is installed on your computer. It is part of the Android Developer Tools package that can be downloaded from this web site:
1. Include the PatchServices.jar Library in Your Project
Open your Android project in Android Studio.
Expand the app\libs folder.
Copy the PatchServices.jar library to the libs project folder and click OK in the Copy dialog. The library file is located in the <TestComplete>\Bin\Extensions\Android folder on your computer.
Add PatchServices.jar to the dependencies list in the app\build.gradle file of your project:
Note: You need to add a library reference to an individual module's build.gradle file, not to the top-level build file.
2. Initialize the PatchServices Library When Application Starts
The main goal of this step is to initialize TestComplete tools when the application starts. There are two ways to do that. If your application has more than one activity, you need to place the initializing line in the constructor of your application.
public class MyApplication extends Application
// The method that initializes TestComplete tools
If there is only one activity in the tested application, you can add the initializing line to the
onCreate method of the activity.
3. (For Android 11) Configure the application manifest
If the application is built with Android SDK 30 for Android version 11, configure the application’s manifest to allow the TestComplete Test Agent to access the application. For this, add one of the following to the manifest file:
– or –
Testing Android Applications (Legacy)
About Testing Android Applications (Legacy)