Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio and MonkeyTalk?

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!

like image 301
Karim Varela Avatar asked May 29 '13 18:05

Karim Varela


2 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 {
    mavenCentral()
  }
  dependencies {
    classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.5'
  }
}
apply plugin: 'com.android.application'
apply plugin: 'android-aspectj'

android {
  buildTypes {
    monkeytalk.initWith(buildTypes.debug)
    monkeytalk {
      applicationIdSuffix ".monkey"
    }
  }
}

dependencies {
  monkeytalkCompile(files("monkey-talk/monkeytalk-agent-2.0.5.jar"))
}

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 https://github.com/georgepapas/android-gradle-monkey-talk-demo/

like image 159
George Papas Avatar answered Nov 15 '22 23:11

George Papas


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">
        <mt:instrument
            srcfile="myapp.apk"
            destfile="myapp-post-instrumented.apk"
            agent="monkeytalk-agent-2.0.1.jar"
            androidsdk="/path/to/your/sdk"
            androidtarget="android-17"
            log="log.txt"
            verbose="true" />
        </target>

</project>

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.

like image 26
Adam Johns Avatar answered Nov 15 '22 21:11

Adam Johns