Home » Android » ant – Android Studio and MonkeyTalk?

ant – Android Studio and MonkeyTalk?

Posted by: admin June 15, 2020 Leave a comment


Has anybody successfully set up MonkeyTalk with Android Studio?

My main problem at this point is I don’t see a way to set the java compiler to aspectj

I believe there’s some way to do this in custom_rules.xml, but I haven’t seen how to do this yet.

This leads to a maybe unrelated problem, but in the newest version of Android Studio that I’m using (0.1.1), I don’t see a way to run an ant build from inside Android Studio.

Any suggestions appreciated!

How to&Answers:

An approach that I have found works well for is to use the the android-gradle-aspject-j plugin found here https://github.com/uPhyca/gradle-android-aspectj-plugin

What I have done is create a new build type (monkeytalk), included the monkey talk jar as a compile dependency for only this build type and applied the above mentioned aspectj plugin. This ensures that the monkey talk weaving occurs for the monkey talk build type.

Here is a snippet of what my build xml looks like

buildscript {
  repositories {
  dependencies {
    classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.5'
apply plugin: 'com.android.application'
apply plugin: 'android-aspectj'

android {
  buildTypes {
    monkeytalk {
      applicationIdSuffix ".monkey"

dependencies {

I also added an AndroidManifest.xml file for the monkey talk build types which adds the required permissions, i.e. GET_TASKS and INTERNET

For a complete sample app, have a look at this github repo


MonkeyTalk (as of version 2.0.1) has now released tools to “instrument” your already built regular apk with MonkeyTalk independent of any IDE. Steps to complete this instrumentation process in OS X:

1.Download MonkeyTalk 2.0.1 Pro Beta

2.Create a new empty folder on desktop titled “example” or whatever you like

3.Copy monkeytalkpro/agents/android/monkeytalk-agent-2.0.1.jar into “example” directory

4.Copy monkeytalkpro/ant/monkeytalkpro-ant-2.0.1.beta.jar into “example” directory

5.Copy your apk file into “example” directory (named myapp.apk for this example)

6.Create a new file called build.xml in “example” directory and fill it with the following:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:mt="antlib:com.gorillalogic.monkeytalk.ant">

    <target name="instru">
            verbose="true" />


7.Open terminal and cd into your “example” directory

8.Issue command ant instru -lib monkeytalkpro-ant-2.0.1.beta.jar

9.The command should run and then produce a monkeytalk compatible apk in your “example” directory titled “myapp-post-instrumented.apk”

WARNING: There seems to be a bug where the instrumentation process will also place another file in your “example” directory titled “myapp-instrumented.apk”, but this file will be empty. So make sure your destination file is not titled “myapp-instrumented.apk” in your build.xml file or this empty file will overwrite your monkeytalk compatible file.


Android studio is built off of Intellij community edition, which, to my knowledge does not have AspectJ support built in.

You could try adding the Intellij AspectJ plugin – it looks like this should make it possible to setup AspectJ in Android Studio, although I haven’t actually tried to get MonkeyTalk working with this yet.


If your Android Studio project is Maven type, than all you need to do is add some AspectJ dependencies, MonkeyTalk-Agent dependency and make maven profile with configuration for those dependencies.

At first you will need to deploy downloaded previously (available here) jar file with MonkeyTalk-Agent for Android to you local Maven repo. If you have proper configuration of maven you can do it with following command:

mvn install:install-file -Dfile=monkeytalk-agent-2.0.4.jar -DgroupId="com.gorillalogic.monkeytalk" -DartifactId="monkeytalk-agent" -Dversion="2.0.4" -Dpackaging="jar" 

When you successfully complete this part, you can edit existing POM file of you project and add following to your project dependencies:




Next step is to create maven profile that could add MonekyTalk during build:


Next step is to edit your app Manifest file giving following permission:

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

Now you project is set and ready to make MonkeyTalk app build. To to this you just need to use during project maven build process your new monkeytalk profile. Example of use in command line:

clean install android:deploy android:run -Pmonkeytalk

Now you can connect with you app trough MonkeyTalk IDE available here.