1. Home
  2. Developers
  3. Android
  4. Testing Apptentive on Android

Testing Apptentive on Android

This document will help you verify that Events and Interactions have been properly configured within your app.

Configuring Test App with Different Apptentive Keys

We recommend creating a new Apptentive app to test out your integration and for exploring Apptentive features.

Create a new app on your Apptentive dashboard, go to Settings -> API & Development. You can change what you pass into the Apptentive.register() method, but a better way is to set up a new product flavor so that your dev flavor uses different Apptentive keys than your release flavors. Set the test API key in your AndroidManifest.xml.

Using different flavors

First, set up Manifest Placeholders in your build.gradle to inject a different Apptentive App Key and Signature depending on the flavor you want to build:

android {
    defaultConfig {
        manifestPlaceholders = [
          APPTENTIVE_APP_KEY:"<your_release_app_key>",
          APPTENTIVE_APP_SIGNATURE: "<your_release_app_signature>"
        ];
    }
    productFlavors {
        dev {
            manifestPlaceholders = [
                    APPTENTIVE_APP_KEY: "<your_dev_app_key>",
                    APPTENTIVE_APP_SIGNATURE: "<your_dev_app_key>",
            ];
        }
    }
}

Next, add this line to your manifest:

<meta-data android:name="apptentive_key" android:value="${APPTENTIVE_APP_KEY}"/>
<meta-data android:name="apptentive_signature" android:value="${APPTENTIVE_APP_SIGNATURE}"/>

Now, you can build the dev flavor by opening Android Studio’s Build Variants window, and changing the Build Variant column to devDebug, and then building, or by running the following command in a terminal:

./gradlew :app:assembleDevDebug

Using a test API key during development will allow you to modify Apptentive settings without fear of affecting your live app

Testing the Love Dialog and Rating Dialog

To verify that the Love Dialog has been integrated correctly into your app, you will first need to set up at least one Event.

Once you have done that, open your Love Dialog configuration. Click the Targeting tab, and in the section titled How Often, uncheck Wait for 5 days after the first launch of the current app version. Then, change Wait for 5 launches of the current app version to show the dialog to 0.

Next, you will need to choose which Event that the Love Dialog should be targeted to. In the Where section, choose the Event that you just set up from the dropdown list. If you don’t see it in the list, first verify that you have triggered this Event at least once, so that the server is aware of it.

Finally, launch your app and verify that the Love Dialog appears when you trigger your chosen Event.

Note: If you change the Love Dialog content or logic, you will need to clear the SDK’s cache by clearing your app’s data or uninstalling and reinstalling it (without backups turned on in your manifest), before you will be able to see the changes in your app.

Setup and testing for the Rating Dialog is similar.

Testing Surveys

Just like with Ratings, Surveys require you to create at least one Event.

Once you have created an Event, open Surveys. There, click New Survey, and fill out your test Survey content. After saving the first page, select Publish survey as an independent Interaction. Then, in the Where section, use the Select Event dropdown to choose your Event.

Once you have created the Survey, close and reopen the app so that it is forced to download the latest Interactions, and trigger the Event that you chose for your Survey. You should see the Survey display.

Updated on May 3, 2018

Was this article helpful?

Related Articles