Using latest support library w/ maven.

6,400 views
Skip to first unread message

Mark Andrachek, Jr.

unread,
Sep 28, 2012, 5:16:41 PM9/28/12
to actionba...@googlegroups.com
In my eclipse projects, I've been able to add the ABS library project, and replace the support library jar file without problems, allowing me to use the latest version.  Anyone know if I'll hit problems with a configuration like this with maven? It seems to be working at the moment...

   <dependencies>
        <dependency>
            <groupId>android</groupId>
            <artifactId>android</artifactId>
            <version>4.1_r2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>android.support</groupId>
          <artifactId>compatibility-v4</artifactId>
          <version>r10</version>
        </dependency>
        <dependency>
          <groupId>com.actionbarsherlock</groupId>
          <artifactId>library</artifactId>
          <version>4.1.0</version>
          <type>apklib</type>
          <exclusions>
              <exclusion>
                <groupId>com.google.android</groupId>
                <artifactId>support-v4</artifactId>
              </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

Jake Wharton

unread,
Sep 28, 2012, 5:18:40 PM9/28/12
to actionba...@googlegroups.com
Nope. That is exactly the correct way to do it.

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

Mark Andrachek, Jr.

unread,
Sep 29, 2012, 1:33:32 AM9/29/12
to actionba...@googlegroups.com
Ugh. This works from the command line, but attempting to load it up into intellij, I get lots of errors in the gen-external-apklibs directory regarding missing android.support.v4 classes. Any ideas?

Mark Andrachek, Jr.

unread,
Sep 29, 2012, 1:49:40 AM9/29/12
to actionba...@googlegroups.com
Ok, so I opened up my module settings. For the ~apklib-com.actionbarsherlock_library_4.1.0 module, in the library tab, I added the Maven: android.support:compatibility-v4:r10 library. Same thing for ViewPagerIndicator.. It seems to be working now.

Mark Andrachek, Jr.

unread,
Sep 29, 2012, 2:16:39 AM9/29/12
to actionba...@googlegroups.com
Oh, except it's not. Now it can't find my R.java. *sigh*
It shouldn't have to be this hard, in eclipse OR intellij.

Tomáš Procházka

unread,
Oct 10, 2012, 7:14:20 AM10/10/12
to actionba...@googlegroups.com
Yes, problem is that Idea compile apklib project separate before main project, Eclipse do the same thing. So if you exclude support dependency from sherlock it is missing for compile sherlock apklib :-(
I don't found solution yet. Only way is manually add support library for sherlock projekct after every change in main pom.xml. Is possible use alt+enter on missing class name and it allow quick fix.

Interesting is that android maven plugin works with this configuration is must use the same class path also for compile apklib.
Maybe we should to try add bug/feature request for it here http://youtrack.jetbrains.com/login


Dne sobota, 29. září 2012 8:16:39 UTC+2 Mark Andrachek, Jr. napsal(a):
Message has been deleted

Ondřej Kroupa

unread,
Oct 11, 2012, 8:10:59 PM10/11/12
to actionba...@googlegroups.com
Thanks. Works great!

Dne pátek, 28. září 2012 23:16:42 UTC+2 Mark Andrachek, Jr. napsal(a):

Gal Ben-Haim

unread,
Nov 14, 2012, 2:31:05 AM11/14/12
to actionba...@googlegroups.com
I'm facing the same problem, as I want to use the revision 11 support library that was just released.

is there a solution for doing this with Maven and IDEA ?

Jake Wharton

unread,
Nov 14, 2012, 4:19:31 AM11/14/12
to actionba...@googlegroups.com

If you are using Maven you need to use deploy:deploy-file to upload the new support library jar into your local Maven repository. Make sure you specify the same groupId and artifactId as the existing support library and only update the version.

The usage of deploy:deploy-file is easily Google-able since I'm on mobile and can't paste the full command.

Gal Ben-Haim

unread,
Nov 14, 2012, 4:39:14 AM11/14/12
to actionba...@googlegroups.com
I have the support library in my local repository as I'm using android-sdk deployer - https://github.com/mosabua/maven-android-sdk-deployer

the problem is that adding the support library to pom.xml and adding an exclusion to it in ActionBarSherlock's dependency result in Intellij failing to build ActionBarSherlock.
(it works fine from Maven command line)

Jake Wharton

unread,
Nov 17, 2012, 4:53:34 PM11/17/12
to actionba...@googlegroups.com
You shouldn't need to add an exclusion. The Maven versioning rules should automatically allow the r11 version to take precedence.

Tomáš Procházka

unread,
Nov 19, 2012, 4:27:29 AM11/19/12
to actionba...@googlegroups.com
This is problem if want to use support library imported  to the own repo by https://github.com/mosabua/maven-android-sdk-deployer
It has different groupId :-(

I hope that official support from Google will be soon :-(

--
Ing. Tomáš Procházka


2012/11/17 Jake Wharton <jakew...@gmail.com>

Jake Wharton

unread,
Nov 20, 2012, 11:55:39 AM11/20/12
to actionba...@googlegroups.com, tomas.p...@atomsoft.cz
If it has a different groupId and/or artifactId you should add an <exclude> entry to the ABS dependency and add an explicit dependency on the new version. Something like this:

<dependency>
  <groupId>com.actionbarsherlock</groupId>
  <artifactId>actionbarsherlock</artifactId>
  <version>4.2.0</version>
  <excludes>
    <exclude>
      <groupId>com.google.android</groupId>
      <artifactId>support-v4</artifactId>
    </exclude>
  </excludes>
</dependency>
<dependency>
  <groupId>whatever</groupId>
  <artiactId>support-library</artifactId>
  <version>r11</version>
</dependency>

Tomáš Procházka

unread,
Nov 21, 2012, 12:07:54 AM11/21/12
to actionba...@googlegroups.com, Jake Wharton

Yes. This works from command line but not in Idea and I think that it is bug in Idea. It compile apk lib separately and only with dependencies defined in Sherlock pom.  I will enter bug for it.

Dne 20.11.2012 17:55 "Jake Wharton" <jakew...@gmail.com> napsal(a):
If it has a different groupId and/or artifactId you should add an <exclude> entry to the ABS dependency and add an explicit dependency on the new version. Something like this:

<dependency>
  <groupId>com.actionbarsherlock</groupId>
  <artifactId>actionbarsherlock</artifactId>
  <version>4.2.0</version>
  <excludes>
    <exclude>
      <groupId>com.google.android</groupId>
      <artifactId>support-v4</artifactId>
    </exclude>
  </excludes>
</dependency>
<dependency>
  <groupId>whatever</groupId>
  <artiactId>support-library</artifactId>
  <version>r11</version>
</dependency>

On Monday, November 19, 2012 1:27:29 AM UTC-8, Tomáš Procházka wrote:
This is problem if want to use support library imported  to the own repo by https://github.com/mosabua/maven-android-sdk-deployer
It has different groupId :-(

I hope that official support from Google will be soon :-(

--

Dandre Allison

unread,
Dec 21, 2012, 8:22:10 PM12/21/12
to actionba...@googlegroups.com, Jake Wharton, to...@atomsoft.cz
Has anything come of this bug filing yet? It seems it is still complaining about the exclusion in my POM file. Also, isn't it 

<exclusions><exclusion></exclusion></exclusions>

Dandre Allison

unread,
Dec 24, 2012, 12:09:05 PM12/24/12
to actionba...@googlegroups.com

Eugene Wechsler

unread,
May 18, 2013, 3:41:32 PM5/18/13
to actionba...@googlegroups.com
Hello collegues,

This conversation helped me to think and find the solution for my exact case. May be it would work for others of you. So the problem:

- ABS has old support library (r7) in its dependencies
- ABS has maven as primary build system
- My project requires lates support libraray because of PagerStrips for ViewPager
- My project has ant as build system and I am not going to change it by many reasons
- As some of you I also use IJIDEA for debuging

First I realised that ABS is an actual wrapper above support library. So I don't think it is a good idea to manage multiply versions of it. Let's keep only one version around and we won't have to be fighting with anything. 

What I've done:
- I forked ABS repo
- Put it as git submodule to my project
- Created VCS-based maven repository which is local to ABS project dir. I used approach from here http://blog.dub.podval.org/2010/01/maven-in-project-repository.html
- I installed the only instance of support library into that repo (latest version from google I had in my local Android SDK folder)
- I changed ABS dependency from com.google.android/support-v4 to local.libs/support-v4

After that I am able to use that modified ABS with any project which don't have to contain support lib jar in their libs folder. For IJIDEA I just add module dependency to Maven: local.libs/support-v4 for apk project (for apklib it's added automatically when import from pom.xml)


This solution fits well for me. In any time I can switch back to central repo (as soon as google put latest version there). 
Reply all
Reply to author
Forward
0 new messages