Android Studio and MonkeyTalk?
Asked Answered
A

4

8

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!

Akene answered 29/5, 2013 at 18:12 Comment(0)
I
6

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/

Intercollegiate answered 13/7, 2014 at 7:40 Comment(9)
could you show your project with configured monkeyTalk, please?Cytogenetics
No probs. consider up voting the answer if you find it helpful. CheersIntercollegiate
Thank you for the demo @GeorgePapas. After starting your demo and then going to the MonkeyTalkIDE, it looks like the record button is still disabled. Have you gotten it to work successfully with MonkeyTalk Community?Contrition
@ShyGuy Yes. You'll need to ensure you've connected your ide to the emulatorIntercollegiate
Thank you @GeorgePapas I got it to work. I actually just needed to restart my MonkeyTalkIDE :) I got things working with your sample app, but unfortunately my real app crashes with a VerifyError when trying to load my main activity (something about signature error in the APK file). I know this is beyond the scope of this question now, but have you encountered such a thing before?Contrition
I run your application on the device and connect device in the MonkeyTalk IDE Professional (Connection type set to: Android Emulator or Tethered Device message appears), but record button is still disabled. Any ideas how to resolve this problem? I use Android studio 0.8.2 and usb connectionCytogenetics
@KateGeld it might be related to this issue github.com/uPhyca/gradle-android-aspectj-plugin/issues/2Intercollegiate
this solution works, although I followed instructions from prativas.wordpress.com/2014/08/15/…Sibelius
i am getting the following error Error:Execution failed for task ':app:compileDebugJava'. > No such property: bootClasspath for class: com.android.build.gradle.AppPluginMukden
Z
3

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.

Zigmund answered 7/2, 2014 at 20:46 Comment(5)
I have problem with this approach on windows. Dont know if it is platform specific, but ant task says "BUILD SUCCESSFUL" but no apk is created. When I look to log.txt file, i can see a few thousand lines in this style - [aapt] path\res\values-xxhdpi\drawables.xml:16: error: Resource entry apptheme_textfield_focused_holo_light is already defined. [aapt] res\drawable-xhdpi\apptheme_textfield_focused_holo_light.9.png:0: Originally defined here. then "BUILD FILED" error is printed and some stacktrace from instrumentor. Do i have to specify some libraries or something?Henrietta
Did you copy both jar files into your example directory? Also did you specify the jar with the -lib command line argument?Zigmund
Hmmm I'm not sure what the issue could be. I would start a new topic on the monkey talk forums and explain your issue and paste the stack trace. Usually a member of the monkey talk staff will comment.Zigmund
Thumbs up this approach! You may find however the instrumentation process fails due to issues with unresolvable styles if you are using an app compat library. It looks like an older version of apktool is being used which does not contain references to newer styles as specified in app compat. A workaround for this is to specifiy these styles in your app, although that will most likely leave your app looking weird.Intercollegiate
I got everything right it build successfully, i got the log file but the only thing that i needed is an instrumented APK which i didn't. Why is that and why did it say build successful then? Can somebody help me here.Rasping
A
1

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.

Autocracy answered 30/5, 2013 at 16:25 Comment(2)
Thanks Ben, it turns out the aspectJ plugin is available directly from Preferences->Plugin->Browse repositories. I installed it, but it I don't see an option in Preferences->Java Compiler->Use compiler to pick an ajc compiler, which is a necessary step for MonkeyTalk. Any other ideas?Akene
AFAIK AspectJ support in IDEA is only available in commercial editions, but then out of the box with plug-ins directly supported by JetBrains.Beiderbecke
C
0

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:

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.2</version>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>1.6.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.gorillalogic.monkeytalk</groupId>
            <artifactId>monkeytalk-agent</artifactId>
            <version>2.0.4</version>
        </dependency>

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

<profile>
        <id>monkeytalk</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <version>1.4</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <aspectLibraries>
                            <aspectLibrary>
                                <groupId>com.gorillalogic.monkeytalk</groupId>
                                <artifactId>monkeytalk-agent</artifactId>
                            </aspectLibrary>
                        </aspectLibraries>
                        <showWeaveInfo>true</showWeaveInfo>
                        <verbose>true</verbose>
                        <Xlint>ignore</Xlint>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>test-compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

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.

Counterirritant answered 8/5, 2014 at 14:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.