Announcement Announcement Module
Collapse
No announcement yet.
Android Spring Issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Android Spring Issue

    Hi All,

    I am facing an issue while trying to use the spring android framework. Actually i cant get it to work. Because when i try to import the "spring-android-rest-template-1.0.0.M1.jar" and "spring-android-commons-logging-1.0.0.M1.jar" it gives an error saying "Conversion to Dalvik format failed with error 1
    ". Therefore i was not able to complete the sample program.

    Can someone help me regarding this issue.

    Thanks in advance.

  • #2
    I have exactly the same problem.

    Could you please provide a more detailed install instructions? I use Google API 4 (includes Android 1.6)

    I went this way:
    1. Download http://s3.amazonaws.com/dist.springf...l-1.0.0.M1.zip from http://www.springsource.com/download/community
    2. Pull spring-android-rest-template-1.0.0.M1.jar into eclipse
    3. add spring-android-rest-template-1.0.0.M1.jar to classpath through eclispe menu
    4. I was going to add spring-android-commons-logging-1.0.0.M1.jar but that lead to issue #1 (see below)
    5. So I removed spring-android-commons-logging-1.0.0.M1.jar from classpath again and eclipse finally shut up
    6. I have no idea what to do with the <dependencies> shown at 3.2 http://static.springsource.org/sprin...-template.html My .classpath file is hidden AND rebuild very often by Eclipse. The dependencies are going to be stripped pretty soon. Where shall I place this tags anyways? Randomly as child of <classpath> or as child of <classpath-entry>?
    7. I included the example "3.3 Basic usage example" in my code and get issue #2 described below (Force close)
    My .classpath file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
    	<classpathentry kind="src" path="src"/>
    	<classpathentry kind="src" path="gen"/>
    	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    	<classpathentry kind="lib" path="lib/imageloader.jar"/>
    	<classpathentry kind="lib" path="lib/FlurryAgent.jar"/>
    	<classpathentry kind="lib" path="lib/spring-android-rest-template-1.0.0.M1.jar" sourcepath="lib/spring-android-rest-template-1.0.0.M1-sources.jar">
    	 <dependency>
        <groupId>org.springframework.android</groupId>
        <artifactId>spring-android-rest-template</artifactId>
        <version>${org.springframework.android-version}</version>
       </dependency>
     </classpathentry>
    	<classpathentry kind="lib" path="lib/spring-android-commons-logging-1.0.0.M1.jar"> 
    	  <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
        </dependency> 
      </classpathentry>
    	<classpathentry kind="output" path="bin"/>
    </classpath>
    Issue #1

    Code:
    [2010-11-30 16:00:22 - MyProject] 
    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Lorg/apache/commons/logging/Log;
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.command.dexer.Main.processClass(Main.java:299)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:276)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.command.dexer.Main.access$100(Main.java:56)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:228)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.command.dexer.Main.processOne(Main.java:245)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
    [2010-11-30 16:00:22 - MyProject]   at com.android.dx.command.dexer.Main.run(Main.java:139)
    [2010-11-30 16:00:22 - MyProject]   at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
    [2010-11-30 16:00:22 - MyProject]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [2010-11-30 16:00:22 - MyProject]   at java.lang.reflect.Method.invoke(Method.java:597)
    [2010-11-30 16:00:22 - MyProject]   at com.android.ide.eclipse.adt.internal.sdk.DexWrapper.run(Unknown Source)
    [2010-11-30 16:00:22 - MyProject]   at com.android.ide.eclipse.adt.internal.build.ApkBuilder.executeDx(Unknown Source)
    [2010-11-30 16:00:22 - MyProject]   at com.android.ide.eclipse.adt.internal.build.ApkBuilder.build(Unknown Source)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
    [2010-11-30 16:00:22 - MyProject]   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
    [2010-11-30 16:00:22 - MyProject] 1 error; aborting
    [2010-11-30 16:00:22 - MyProject] Conversion to Dalvik format failed with error 1

    Issue #2 is in next post of this stone age forum software with stupid restrictions which bugs me the 5th time today...
    Last edited by OneWorld123; Nov 30th, 2010, 09:33 AM. Reason: added classpath file

    Comment


    • #3
      Issue #2
      Code:
      11-30 14:35:21.339: INFO/ActivityManager(1283): Process org.dayup.gtask (pid 19008) has died.
      11-30 14:35:21.339: INFO/dalvikvm(19022): WOW: somebody generated [Landroid/graphics/Rect; simultaneously
      11-30 14:35:21.410: DEBUG/dalvikvm(19022): GC freed 4541 objects / 381640 bytes in 79ms
      11-30 14:35:21.425: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.HttpClient', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.<init>
      11-30 14:35:21.425: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 421 (Lorg/apache/commons/httpclient/HttpClient;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.425: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x0003
      11-30 14:35:21.425: DEBUG/dalvikvm(19022): Making a copy of Lorg/springframework/http/client/CommonsClientHttpRequestFactory;.<init> code (60 bytes)
      11-30 14:35:21.425: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpClient;)
      11-30 14:35:21.425: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.methods.GetMethod', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.createCommonsHttpMethod
      11-30 14:35:21.425: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 431 (Lorg/apache/commons/httpclient/methods/GetMethod;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.425: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x0022
      11-30 14:35:21.425: DEBUG/dalvikvm(19022): Making a copy of Lorg/springframework/http/client/CommonsClientHttpRequestFactory;.createCommonsHttpMethod code (204 bytes)
      11-30 14:35:21.449: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.methods.DeleteMethod', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.createCommonsHttpMethod
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 429 (Lorg/apache/commons/httpclient/methods/DeleteMethod;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x0028
      11-30 14:35:21.449: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.methods.HeadMethod', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.createCommonsHttpMethod
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 432 (Lorg/apache/commons/httpclient/methods/HeadMethod;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x002e
      11-30 14:35:21.449: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.methods.OptionsMethod', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.createCommonsHttpMethod
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 433 (Lorg/apache/commons/httpclient/methods/OptionsMethod;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x0034
      11-30 14:35:21.449: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.methods.PostMethod', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.createCommonsHttpMethod
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 434 (Lorg/apache/commons/httpclient/methods/PostMethod;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x003a
      11-30 14:35:21.449: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.methods.PutMethod', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.createCommonsHttpMethod
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 435 (Lorg/apache/commons/httpclient/methods/PutMethod;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x0040
      11-30 14:35:21.449: ERROR/dalvikvm(19022): Could not find class 'org.apache.commons.httpclient.methods.TraceMethod', referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.createCommonsHttpMethod
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to resolve new-instance 437 (Lorg/apache/commons/httpclient/methods/TraceMethod;) in Lorg/springframework/http/client/CommonsClientHttpRequestFactory;
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x22 at 0x0046
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpMethodBase;)
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpMethodBase;)
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpClient;)
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpClient;)
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpMethodBase;)
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpClient;)
      11-30 14:35:21.449: INFO/dalvikvm(19022): Could not find method org.apache.commons.httpclient.HttpClient.getHttpConnectionManager, referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.destroy
      11-30 14:35:21.449: WARN/dalvikvm(19022): VFY: unable to resolve virtual method 1880: Lorg/apache/commons/httpclient/HttpClient;.getHttpConnectionManager ()Lorg/apache/commons/httpclient/HttpConnectionManager;
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x6e at 0x0004
      11-30 14:35:21.449: DEBUG/dalvikvm(19022): Making a copy of Lorg/springframework/http/client/CommonsClientHttpRequestFactory;.destroy code (52 bytes)
      11-30 14:35:21.457: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpClient;)
      11-30 14:35:21.457: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpMethodBase;)
      11-30 14:35:21.457: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpClient;)
      11-30 14:35:21.457: WARN/dalvikvm(19022): VFY: unable to find class referenced in signature (Lorg/apache/commons/httpclient/HttpClient;)
      11-30 14:35:21.457: INFO/dalvikvm(19022): Could not find method org.apache.commons.httpclient.HttpClient.getHttpConnectionManager, referenced from method org.springframework.http.client.CommonsClientHttpRequestFactory.setReadTimeout
      11-30 14:35:21.457: WARN/dalvikvm(19022): VFY: unable to resolve virtual method 1880: Lorg/apache/commons/httpclient/HttpClient;.getHttpConnectionManager ()Lorg/apache/commons/httpclient/HttpConnectionManager;
      11-30 14:35:21.457: DEBUG/dalvikvm(19022): VFY: replacing opcode 0x6e at 0x000e
      11-30 14:35:21.457: DEBUG/dalvikvm(19022): Making a copy of Lorg/springframework/http/client/CommonsClientHttpRequestFactory;.setReadTimeout code (68 bytes)
      11-30 14:35:21.457: WARN/dalvikvm(19022): threadid=23: thread exiting with uncaught exception (group=0x4001b170)
      11-30 14:35:21.457: DEBUG/FlurryAgent(19022): Ending session
      11-30 14:35:21.457: DEBUG/LocationManager(19022): removeUpdates: listener = com.flurry.android.FlurryAgent@44f63088
      11-30 14:35:21.457: ERROR/AndroidRuntime(19022): Uncaught handler: thread Thread-12 exiting due to uncaught exception
      11-30 14:35:21.480: ERROR/AndroidRuntime(19022): java.lang.NoClassDefFoundError: org.apache.commons.httpclient.HttpClient
      11-30 14:35:21.480: ERROR/AndroidRuntime(19022):     at org.springframework.http.client.CommonsClientHttpRequestFactory.<init>(CommonsClientHttpRequestFactory.java:61)
      11-30 14:35:21.480: ERROR/AndroidRuntime(19022):     at myProject where I implemented example 3.2
      11-30 14:35:21.480: ERROR/AndroidRuntime(19022):     at java.lang.Thread.run(Thread.java:1096)
      I hope somebody here can provide us rapid help. It's surely just a mistake in implenting

      Comment


      • #4
        Solved it!

        Thats the way I got it working in eclipse:
        1. Pull spring-android-rest-template-1.0.0.M1.jar into eclipse and add it to build path
        2. Download http://apache.imsam.info//httpcompon...client-3.1.zip from http://hc.apache.org/downloads.cgi
        3. Pull the JAR-file into eclipse and add to build path
        4. Done! No messing with dependencies was required for example 3.3



        Comment


        • #5
          no luck

          I'm using a different way, Not messing with dependencies. I have my android project in eclipse. And when i try to import the rest template jar file it gives the "Conversion to Dalvik format failed with error 1". I tried finding the cause why this is happening, and it says, The android VM cannot convert the content of the jar files in to the DEX format. I tried different versions of android projects. 2.1 , 2.2 and etc. And tried updating the ADT plug-in in eclipse as well. But no luck. Keeps getting the same error.

          Comment


          • #6
            Hi,

            I'm getting the error once i add the spring-android-rest-template-1.0.0.M1.jar file. Can you provide me with the jar file which you imported. Then i can try whats the issue with my android project. It will be a big help.

            Thanks

            Comment


            • #7
              hey nala,

              in my initial post in point 1 I wrote a link to a zip file. I took the jar-file from the bin folder in this file.
              Dont add the logging...jar to your build path. its in this version already included in the other file.

              Post your error messages...

              Comment


              • #8
                Hi oneworld,

                I finally made the code working by using a rest template jar which downloaded separately. However it generates an error in the example. the line is

                restTemplate.setRequestFactory(new CommonsClientHttpRequestFactory());

                the error message says "Type CommonsClientHttpRequestFactory cannot be resolved to a type".

                But if i comment out that line still the code works fine. It gives the JSON which returns from the google.

                I tried using the the jar file which u were referring. "commons-httpclient-3.1". But it ddint work for me. Still it generates the error in that line regarding the commonsClientHttpRequestFactory.

                Thanks

                Comment


                • #9
                  I've created a defect for the duplicate dependency error you are seeing. I'm looking into this, and will hopefully have a resolution for you soon.

                  https://jira.springframework.org/browse/ANDROID-13

                  Thanks for your feedback!

                  Comment


                  • #10
                    Problem with parameterized lists

                    I'm using GSON library for json serialization/deserialization, in order to correctly handle lists GSON needs to know the List contents type this happens by passing the library an instance of ParameterizedType (fromJson method in GSON takes as a parameter an instance of Type a parent of both Class and ParameterizedType).

                    The problem is that I'm doing all the serialization/deserialization work in a custom HttpMessageConverter through the restTemplat but all the methods take Class object to represent the response type but Class object doesn't retain the lists parameter type so I can't deserialize lists.

                    Any ideas?

                    Comment


                    • #11
                      I put together a blog post and sample application for using Maven with Spring Android. it contains a simple pom.xml example for building an android app with dependencies. I'll be incorporating a lot of this information into the documentation for the next milestone release.

                      http://blog.springsource.com/2010/12...-maven-part-1/

                      Comment


                      • #12
                        glad I found this post, it solved my problem that I had

                        Comment


                        • #13
                          its pretty good. I like the rhyming and the flow of the lyrics. you are also very creative. now it just depends on what kind of music it goes to. I like the lyrics but that's only part of the song. but good luck with the song! :

                          Comment

                          Working...
                          X