Thursday, 26 February 2015

Monkey Talk integration with Android Studio

Monkey talk is an excellent tool to run feature tests, which simulates the interaction of the user with the application.

Unfortunately it does not has good integration with Android Studio, which reduces the among of users. In this tutorial I am going to show how to do it on more manual way, with a simple project.

1. Add the AspectJ plugin
1.1 Go to the main build.gradle file and add the follow one, inside the dependencies, like this.

classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.5'

1.2 In the build.gradle file of the module "app" add the follow line at the top, like this:

apply plugin: 'android-aspectj'

2. Add Monkey talk library
2.1 Download the latest version of MonkeyTalk Agent from their web page. It is contained inside the IDEs.
2.2 Inside of the module app, create a new folder called monkey-libs and paste the Monkey Talk jar library inside.
2.3 Open the build.gradle file of the app and paste the follow lines.
2.3.1 Paste the follow code inside of the buildTypes:

        monkeytalk {
            applicationIdSuffix ".monkey"

2.3.2 Paste the follow code inside of the dependencies:

monkeytalkCompile fileTree(dir: 'monkey-libs', include: ['*.jar'])

Here is the example:

3. Include the permissions
Just in case you have not added them, add the required permissions to the Manifest file.
3.1 Open the Android Manifest file.
3.2 Copy the follow line into the manifest file. This will adds the Get task and internet permissions.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_TASKS" />

4. Run the app
4.1 To run the app, open the Terminal or the console and type the follow:

./gradlew clean installMonkeytalk

This command will compile the app and install it into the existence device connected.

Note1: The method above does not works with the version 1.1.0 of the android gradle tool, but the version 1.0.0.

Note2: I have tested the method above with simple projects but with big projects actually it fails. So, good luck!

Source code:



  1. I followed all instructions above but didn't work for me. I'm currently using Android Studio 1.3.2. Any other idea on how to integrate monkeytalk w Android Studio? TIA

    1. Hi: What error do you get? How do you know that Monkey talk is not working?

  2. I've tried all possibility that i can find via Google, it doesn't work with my project.. but i can get it work with simple projects.

    Error:(49, 0) Gradle DSL method not found: 'monkeytalkCompile()'
    Possible causes:The project '' may be using a version of Gradle that does not contain the method.
    Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
    Apply Gradle plugin

    1. Hi:
      Could you provides me the version of gradle you are using? Note that MonkeyTalk for Android studio does not support the last version of Gradle. This includes the last version for plugin that Google developered for Android.

      Also be aware that the company behind Monkey talk, Cloud monkey, has been bought by Oracle. For now all the web pages related with MonkeyTalk has been shutted down. The future of MonkeyTalk is unknown.

      Good luck!

    2. thx for reply, i'm using gradle 2.4, i've tried gradle 2.7 and plugin 1.3.+, 1.2.+ for my personal project, never get working, the simple project also using gradle 2.4 and plugin 1.3.+, i can get it work with monkey talk

    3. MonkeyTalk was done for eclipse and it has some problem of integration with Android Studio. If you check my sample project, it works with gradle 2.2.1 and the plugin version for gradle in Android Studio is 1.0.0.

      You might want to increase the version bit by bit, but since Cloud Monkey has been shutted down, there is not official support for Monkey Talk in Android Studio. Sorry about that.

  3. btw, my app project depends on another library project, do i need to add some configuration in the libs project?

    1. Please, read carefully this post and check my example. It contains all the details to integrate Monkey Talk into Android Studio.