Over a million developers have joined DZone.
Gold Partner

Spring-Android Issue integrating RestTemplate

· Mobile Zone

The Mobile Zone is brought to you in partnership with Apptimize.  Discover the 5 little know reasons your app is underperforming and how to better understand your customers mobile needs.

I started working on some REST client Android development. I have spent the past 1-2 month reading books, and just looking around the internet for good resources, so I could feel I had a complete picture as to what my current skills could best be used to develop.

I started using the Spring Tool Set (STS) to develop my android app. That worked ok, but I have been a long time Intellij developer. Now with the release of IDEA X (ideaIU-98.520), there is android support.

Now there are plenty of books out there to learn Android, and I can tell you, none of them worked for me as a single source to give me the picture I needed to get business apps working.

BOOKS I read:

  • Android Application Development [2009]
  • Beginning Android 2 [2010]
  • Hello_Android_3rd_Edition [2010]
  • Pro Android 2 [2010]
  • Professional Android 2 Application Development [2010]
  • Unlocking Android [2009] (partial)

Getting the basics to say hello world was easy, but when you want to move past that, you really need to dig (imho).

What I really wanted to do, is integrate Spring-Mobile, and the RestTemplate into my android all so I can leverage the Springframework tools.

I found http://www.springsource.org/spring-mobile which actually is a server side framework for detecting Browser verse mobile devices. So don’t let the name fool you.

I then found http://static.springsource.org/spring-android/docs/1.0.x/reference/htmlsingle/ which is actually a client side library that helps connect to REST based services.

The Spring Android documentation says to get the following libraries:

spring-android-commons-logging-1.0.1.BUILD-20101129.090047-10.jar
spring-android-rest-template-1.0.1.BUILD-20101129.090103-10.jar
commons-httpclient-3.1.jar

I was very confused, as I cannot find any Spring example where using IDEA, or Eclipse, that Maven is used for Rapid Development. I spent several hours trying to find a working solution, and could not find this documented anywhere. Frustrating! Finally I downloaded the 3 jars, then added them to my ./lib directory and added all 3 Libraries to my Third-Party Jars in my IDEA project.

As soon as I built the application, I get this exception:

java.lang.IllegalArgumentException: already added: Lorg/apache/commons/logging/Log;

 

This led me to see that for some reason, spring-android-commons-logging-1.0.1.BUILD-20101129.090047-10.jar was not going to work. I removed that jar, and the error went away, and I was able to get the example to work.

From http://www.baselogic.com/blog/development/spring-android-issue-integrating-resttemplate

The Mobile Zone is brought to you in partnership with Apptimize.  Learn more about app optimization methods that help teams identify user preferences, decide the next iterative changes to make, and validate them through testing.

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}