I've been banging my head against a wall for some time trying to get maven, robolectric, actionbar sherlock, and intellij, to all play nicely. I've given up on building with intellij for now and am focusing on maven.
I have an app with an action bar when I skip the tests in the maven build (which tells me I'm good to go on the ActionBar integration front). The IntelliJ build fails on ManifestParsingTest.java complaining that it doesn't know where junit is (among other issues).
Robolectric integration
I already had Robolectric running successfully in the project. I copied the files from Jake Wharton's gist into src/test/java/com/blah/blah/support/
(except ShadowSherlockFragmentActivity.java
which lives in src/test/java/com/blah/blah/support/shadows/
) and put this line in the constructor for my custom test runner (lives in support
folder):
ActionBarSherlock.registerImplementation(ActionBarSherlockRobolectric.class);
mvn errors
I'm running into these build errors (IntelliJ also has red squigglies for the same stuff):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:testCompile (default-testCompile) on project Blah: Compilation failure: Compilation failure:
[ERROR] /Users/clatislaw/Documents/Code/Android/projectName/src/test/java/com/blah/blah/support/SherlockResourceLoader.java:[29,9] cannot find symbol
[ERROR] symbol : constructor ResourceLoader(int,java.lang.Class,java.util.List<java.io.File>,java.io.File)
[ERROR] location: class com.xtremelabs.robolectric.res.ResourceLoader
[ERROR] /Users/clatislaw/Documents/Code/Android/projectName/src/test/java/com/blah/blah/support/SherlockResourceLoader.java:[45,5] method does not override or implement a method from a supertype
[ERROR] /Users/clatislaw/Documents/Code/Android/projectName/src/test/java/com/blah/blah/support/ActionBarSherlockTestRunner.java:[39,37] resourceLoaderForRootAndDirectory has private access in com.xtremelabs.robolectric.RobolectricTestRunner
[ERROR] /Users/clatislaw/Documents/Code/Android/projectName/src/test/java/com/blah/blah/support/ActionBarSherlockTestRunner.java:[47,30] cannot find symbol
[ERROR] symbol : method getResourcePath()
[ERROR] location: class com.xtremelabs.robolectric.RobolectricConfig
[ERROR] /Users/clatislaw/Documents/Code/Android/projectName/src/test/java/com/blah/blah/support/ActionBarSherlockTestRunner.java:[48,9] resourceLoaderForRootAndDirectory has private access in com.xtremelabs.robolectric.RobolectricTestRunner
[ERROR] /Users/clatislaw/Documents/Code/Android/projectName/src/test/java/com/blah/blah/support/ActionBarSherlockTestRunner.java:[38,3] method does not override or implement a method from a supertype
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blah.blah</groupId>
<artifactId>projectName</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Project Name App</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r6</version>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<version>4.1.0</version>
<type>apklib</type>
</dependency>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<!-- See http://code.google.com/p/maven-android-plugin/ -->
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<sdk>
<platform>15</platform>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Is there some project config I'm missing?