Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you integrate Robolectric, Maven, ActionBarSherlock (and preferably + IntelliJ) into an Android project?
    primarykey
    data
    text
    <p>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.</p> <p>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).</p> <p><strong>Robolectric integration</strong></p> <p>I already had Robolectric running successfully in the project. I copied the files from <a href="https://gist.github.com/3803294">Jake Wharton's gist</a> into <code>src/test/java/com/blah/blah/support/</code> (except <code>ShadowSherlockFragmentActivity.java</code> which lives in <code>src/test/java/com/blah/blah/support/shadows/</code>) and put this line in the constructor for my custom test runner (lives in <code>support</code> folder):</p> <pre><code>ActionBarSherlock.registerImplementation(ActionBarSherlockRobolectric.class); </code></pre> <p><strong>mvn errors</strong></p> <p>I'm running into these build errors (IntelliJ also has red squigglies for the same stuff):</p> <pre><code>[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&lt;java.io.File&gt;,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 </code></pre> <p><strong>pom.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.blah.blah&lt;/groupId&gt; &lt;artifactId&gt;projectName&lt;/artifactId&gt; &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;apk&lt;/packaging&gt; &lt;name&gt;Project Name App&lt;/name&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;com.google.android&lt;/groupId&gt; &lt;artifactId&gt;android&lt;/artifactId&gt; &lt;version&gt;4.0.1.2&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.pivotallabs&lt;/groupId&gt; &lt;artifactId&gt;robolectric&lt;/artifactId&gt; &lt;version&gt;1.1&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.8.2&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.google.android&lt;/groupId&gt; &lt;artifactId&gt;support-v4&lt;/artifactId&gt; &lt;version&gt;r6&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.actionbarsherlock&lt;/groupId&gt; &lt;artifactId&gt;library&lt;/artifactId&gt; &lt;version&gt;4.1.0&lt;/version&gt; &lt;type&gt;apklib&lt;/type&gt; &lt;/dependency&gt; &lt;build&gt; &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;!-- See http://code.google.com/p/maven-android-plugin/ --&gt; &lt;groupId&gt;com.jayway.maven.plugins.android.generation2&lt;/groupId&gt; &lt;artifactId&gt;android-maven-plugin&lt;/artifactId&gt; &lt;version&gt;3.2.0&lt;/version&gt; &lt;configuration&gt; &lt;sdk&gt; &lt;platform&gt;15&lt;/platform&gt; &lt;/sdk&gt; &lt;/configuration&gt; &lt;extensions&gt;true&lt;/extensions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>Is there some project config I'm missing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload