Trouble with finding @style/Theme.Sherlock with Maven build

2,664 views
Skip to first unread message

Johan Pelgrim

unread,
Mar 7, 2012, 10:56:37 AM3/7/12
to actionba...@googlegroups.com
Hi Jake / others,

I'm having trouble including the actionbarsherlock apklib in my maven build.

I have a multi-module pom. I have this in my parent-pom (among other stuff of course):

<repositories>
  <repository>
    <id>jakewharton</id>
  </repository>
</repositories>

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.actionbarsherlock</groupId>
      <artifactId>library</artifactId>
      <version>3.5.1</version>
      <type>apklib</type>
    </dependency>
  </dependencies>
</dependencyManagement>

And this in my project-pom:

<dependencies>
  <dependency>
    <groupId>com.actionbarsherlock</groupId>
    <artifactId>library</artifactId>
    <version>3.5.1</version>
  </dependency>
</dependencies>

When adding the android:theme="@style/Theme.Sherlock" to my application or activities in my AndroidManifest.xml I get the following error when building my project:

AndroidManifest.xml:22: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Sherlock').

I have included the library-project in Eclipse, so that is showing no errors.

I.e. the library is not added correctly to my project's build phase. What am I doing wrong?

Thanks very much in advance for your help. I'm stuck at the moment.

Kind regards,

Johan Pelgrim
The Netherlands

Jake Wharton

unread,
Mar 7, 2012, 11:11:19 AM3/7/12
to actionba...@googlegroups.com

I am fairly certain that you need to specify the apklib type in your project again even though you put it in the dependency management section. It still seems to default to the .jar when omitted.

Johan Pelgrim

unread,
Mar 7, 2012, 12:59:04 PM3/7/12
to actionba...@googlegroups.com
Hi Jake,

Thanks for the swift reply! Appreciate it!

I'm getting a whole bunch of new errors now...

[ERROR] (…)/target/unpack/apklibs/com.actionbarsherlock_library_apklib_3.5.1/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java:[54,85] package android.app.ActionBar does not exist
[ERROR] (…)/target/unpack/apklibs/com.actionbarsherlock_library_apklib_3.5.1/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java:[56,77] package android.app.ActionBar does not exist
[ERROR] (…)/target/unpack/apklibs/com.actionbarsherlock_library_apklib_3.5.1/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java:[70,27] cannot find symbol
symbol  : class ActionBar
location: package android.app
[ERROR] (…)/target/unpack/apklibs/com.actionbarsherlock_library_apklib_3.5.1/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java:[81,37] package android.app.ActionBar does not exist
[ERROR] (…)/target/unpack/apklibs/com.actionbarsherlock_library_apklib_3.5.1/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java:[91,57] package android.app.ActionBar does not exist
[ERROR] (…)/target/unpack/apklibs/com.actionbarsherlock_library_apklib_3.5.1/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java:[91,78] cannot find symbol
symbol  : class FragmentTransaction

But I'm reading that it has to do with upgrading the android dependency to v3.2. I'll figure it out... and maybe move to 4.0.0.RC1 in the process ;-)

Thanks again!

Johan

Jake Wharton

unread,
Mar 9, 2012, 12:46:52 PM3/9/12
to actionba...@googlegroups.com
That one looks like you're compiling against an SDK before honeycomb. For ABS v3.5 Android 3.2 is required.

---
Jake Wharton
http://about.me/jakewharton

Johan Pelgrim

unread,
Mar 9, 2012, 5:37:27 PM3/9/12
to actionba...@googlegroups.com
Hi Jake,

Thanks for the follow up. Yes, that was it. Already had stuff working yesterday (your tip to look at the Gaug.es poms in another thread was the key ;-)

Thanks for all the hard work Jake! Awesome stuff!

Cheers,

Johan

Rainer Baun

unread,
Mar 10, 2012, 7:55:21 AM3/10/12
to actionba...@googlegroups.com
Hi,

I am new to maven and try to set up a project with abs 4.0, maven and eclipse.

So far I added the dependency for abs, but i cant import any of its classes in eclipse. Do i Have to add the maven dependency AND add the project in eclipse as a library project like building without maven?

So this makes double work with maven, and android library projects?

Im really confused, I dont know if i set up my environment wrong or if this is normal behaviour :-(

2012/3/9 Johan Pelgrim <johan....@gmail.com>

Dandre Allison

unread,
Mar 10, 2012, 12:17:19 PM3/10/12
to actionba...@googlegroups.com
the library for 4.0 has a jar and a apklib, then there's the compatibility jar too. Also make sure to build with Android 4.0 (or 4.0.3 I think). Here's my snippet: (from the Gaug.es app):

<properties>
        <abs.version>4.0.0-RC1</abs.version>
</properties>

    <repositories>
        <repository>
            <id>jakewharton-release</id>
            <url>http://r.jakewharton.com/maven/release/</url>
        </repository>
    </repositories>
<!-- ActionBarSherlock(ABS): compatibility action bar -->
        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>library</artifactId>
            <version>${abs.version}</version>
            <type>apklib</type>
        </dependency>
        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>library</artifactId>
            <version>${abs.version}</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>plugin-support-lib</artifactId>
            <version>${abs.version}</version>
        </dependency>

Side note: I think it still does give the resource issue in eclipse, but you can use the classes. And most importantly it will still compile and run through Maven. You might have to do a include library to Eclipse to resolve that problem. Gaug.es App source for reference.

Jake Wharton

unread,
Mar 10, 2012, 11:10:39 PM3/10/12
to actionba...@googlegroups.com

You should only have to depend on the apklib of the library for 4.0. The support-lib jar no longer is a separate plugin and you'd only need the jar dependency for certain types of testing.

Tyler Howarth

unread,
Mar 10, 2012, 11:19:53 PM3/10/12
to actionba...@googlegroups.com
Could you please post what you did to fix the eclipse errors?  Maven is building fine and deploying to my device, but Eclipse cannot resolve anything related to the actionbarlibraries, this includes your original theme.Sherlock usage, and any other references to ABS.


For instance

import com.actionbarsherlock.app.SherlockActivity;

public class SomeActivity extends SherlockActivity {

the import com.actionbarsherlock cannot be resolved.

My pom.xml looks like this:

<repositories>

<repository>

<id>jakewharton</id>

<url>http://r.jakewharton.com/maven/release</url>

</repository>

</repositories>


<dependency>

<groupId>com.actionbarsherlock</groupId>

<artifactId>library</artifactId>

<version>${abs.version}</version>

<type>apklib</type>

</dependency> 

<dependency>

            <groupId>com.actionbarsherlock</groupId>

            <artifactId>library</artifactId>

            <version>${abs.version}</version>

            <type>jar</type>

            <scope>provided</scope>

        </dependency>

James Morgan

unread,
Mar 11, 2012, 11:12:17 AM3/11/12
to actionba...@googlegroups.com
I'm also having the same issue. Ive tried lots of to maven etc to get this working but am totally out of ideas? Ive tried several types of theme and custom themes but none work.

I can reference sherlocks resource via code i.e.

        setTheme(com.actionbarsherlock.R.style.Sherlock___Theme_Light);

but when I start it up I still get the error, please set the theme to sherlock Theme.Light etc........

I'm using maven android plugin 3.1.1, eclipse STS 2.8.0, maven 3.0.0. My pom.xml is as follows but I still keep on getting the error mentioned before.

Pom.xml


       <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>library</artifactId>
            <version>4.0.0</version>

            <type>apklib</type>
        </dependency>
        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>library</artifactId>
            <version>4.0.0</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>


Error:

Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Sherlock').    AndroidManifest.xml    /MyApplication    line 19    Android AAPT Problem

Android versions:
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>

Johan Pelgrim

unread,
Mar 11, 2012, 5:04:41 PM3/11/12
to actionba...@googlegroups.com
Hi Tyler / James,

You have to keep in mind that Maven and Eclipse are two separate things. Yes, the m2eclipse plugin does dependency management and stuff, but (unfortunately) it doesn't add the apklib dependency to your Eclipse classpath, so you have to do that manually to get rid of all the errors in Eclipse.
  1. Download the ZIP / Tarball from http://actionbarsherlock.com
  2. Extract it somewhere (I extracted it to /usr/local/src/JakeWharton-ActionBarSherlock-4.0.0)
  3. In Eclipse create a new Android project from existing sources and browse to /usr/local/src/JakeWharton-ActionBarSherlock-4.0.0/library
  4. Now, in your project go to your project properties and select the Android configuration.
  5. Add the recently created actionbarsherlock Library project in the Library section below (see screenshot)

If things are still a bit wobbly a good old "Project | Clean" (and a build after that) in Eclipse or Maven "Update Project Configuration" or "Update Dependencies" (when you right click in your project folder) sometimes fixes everything... I know... This is a bit crazy and intermittent behavior but once fixed your project should be fine for sometime.



Hope this helps.

Cheers,

Johan.

P.S. James, I have the same sections in my pom.xml, so that should be fine. I don't have the "<scope>compile</scope>" on the jar-library dependency though...
Message has been deleted

Johan Pelgrim

unread,
Mar 11, 2012, 7:29:23 PM3/11/12
to actionba...@googlegroups.com

Groet,

Hi Tyler,

You have to right-click the android-support-v4.jar file in the libs-directory and add it to the build path.

Inline image 1

Cheers,

Johan

On Sun, Mar 11, 2012 at 11:44 PM, Tyler Howarth <tylerh...@gmail.com> wrote:
Johan, Thanks for posting this.  

When I create a new android from the /library source, Eclipse throws me tons of errors.  

Any ideas?

Screen Shot 2012-03-12 at 12.26.23 AM.png
Message has been deleted

rkay...@uottawa.ca

unread,
Jan 8, 2013, 11:27:32 AM1/8/13
to actionba...@googlegroups.com
I'm having a similar problem too.

I got past the m2e issues by importing the actionbarsherlock project into my workspace and referencing it from there. However, I can't access any of its resources in xml, only through java code.

Has anyone managed to fix this? I'm still getting the NullPointerException on getSupportActionbar(), which seems to be caused from using the wrong Theme.

Thanks,

rkay...@uottawa.ca

unread,
Jan 8, 2013, 11:28:13 AM1/8/13
to actionba...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages