So today I thought I’ll have a look at getting the robotium-maps library integrated with Robotium and see how well it works. It turns out though that there isn’t a lot of documentation, or any for that matter that I could find on robotium-maps. The first challenge was I am using Android Studio which has a gradle build system not Maven and so integration is less clear.
To get the code to build I had to change the pom file from the checked out robotium-maps code to add the mvnrepository because I didn’t have one setup and changed the versions of robotium solo that was available.
Steps to build the code:
1) Download the robotium maps code
2) Download and install Maven
3) Set JAVA_HOME to your JDK folder
4) Add maven bin folder to your PATH
5) Install the maps.jar to your local maven repository.
6) Edit the pom.xml and then run the build and get the jar!
Download the robotium maps code
The code for robotium-maps can be found on their github site. You can either download it using git if it is installed, otherwise just download the zip and extract it.
Download and install Maven
Not everyone is familiar with maven. Head over to http://maven.apache.org/download.cgi and download the maven zip file. Extract it to C:\
Set JAVA_HOME to your JDK folder
In your system environment variables if it doesn’t exist already the create a variable called JAVA_HOME and set the path to your JDK install folder (not the bin folder)
Add maven bin folder to your PATH
In your system environment variables edit the PATH variable and add the maven bin folder to it, e.g. C:\apache-maven-3.2.3\bin
Install the maps.jar to your local maven repository
This is the instruction that is on the github site for robotium maps. This is to put the google maps jar into the local maven repository so that the build works. My version of maps had moved on so I ran the command C:\Users\Marc\AndroidStudioProjects\robotium-maps>mvn install:install-file -Dfile=”C:/android-studio/sdk/add-ons/addon-g
oogle_apis-google-19/libs/maps.jar” -DgroupId=com.google.android.maps -DartifactId=maps -Dversion= -Dpackaging=jar if you make sure that you run this command not in the folder where the robotium-maps project is because otherwise, it tries to build the robotium-maps library and will fail.
Edit the pom.xml and then run the build and get the jar
I had to change the robotium-maps pom.xml file slightly because my maven setup was clean and I didn’t have any other repositories configured. I added the following to the pom.xml at the bottom of the file inside
<repositories> <repository> <id>my-repo1</id> <name>MVNRepository</name> <url>http://mvnrepository.com/</url> </repository> </repositories>
I also needed to change the robotium versions to 3.3 because 3.3.1-SNAPSHOT didn’t exist on the http://mvnrepository.com repository.
Finally, running mvn install in the folder where the robotium-maps pom.xml file is, should build and create the jar. Go into the target folder and you will see robotium-maps-3.3.jar
To test it for now I am just going to put it into a lib folder in the project as I haven’t yet worked out how to add jars to local gradle repositories.