• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

NoSuchMethodError

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am working on a project in android, where I am trying to upload any file from my phone to my private cloud. So, for that I am using swift joss API.
I have imported the dependency: compile 'org.javaswift:joss:0.9.14' in build.gradle file.
When I compile it get 2 warnings:

Warning:Dependency org.apache.httpcomponents:httpclient:4.2.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
        In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.2.1 is ignored for release as it may be conflicting with the internal version provided by Android.
        In case of problem, please repackage it with jarjar to change the class packages

I anyways proceeded to run the code. But I get run time error every time while uploading the file.
The error is :
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime: FATAL EXCEPTION: Thread-13339
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime: Process: com.hfad.jossdemo, PID: 2758
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime: java.lang.NoSuchMethodError: No direct method <init>(Ljava/io/File;)V in class Lorg/apache/http/entity/FileEntity; or its super classes (declaration of 'org.apache.http.entity.FileEntity' appears in /system/framework/org.apache.http.legacy.boot.jar)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.instructions.UploadPayloadFile.getEntity(UploadPayloadFile.java:20)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.instructions.UploadInstructions.getEntity(UploadInstructions.java:130)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.swift.SwiftStoredObject.uploadObject(SwiftStoredObject.java:79)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.swift.Swift.uploadObject(Swift.java:330)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.command.mock.object.UploadObjectCommandMock.callSwift(UploadObjectCommandMock.java:28)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.command.mock.core.CommandMock.call(CommandMock.java:62)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.client.core.AbstractStoredObject.directlyUploadObject(AbstractStoredObject.java:202)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.client.core.AbstractStoredObject.uploadObject(AbstractStoredObject.java:145)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at org.javaswift.joss.client.core.AbstractStoredObject.uploadObject(AbstractStoredObject.java:214)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at com.hfad.jossdemo.MainActivity$2.run(MainActivity.java:126)
06-07 07:59:59.243 2758-3194/com.hfad.jossdemo E/AndroidRuntime:     at java.lang.Thread.run(Thread.java:818)

The line of code where the error traces back to is:

someFile.uploadObject(new File(file_path));

What I can gather till now is that, there is some kind of difference in the files that are being used at compile and run time. Or there are different versions of files being used at different places.
I am new to android and unable to locate where the fault lies.

Any valuable suggestions are welcome! Please help.

Thanks!
 
Bartender
Posts: 7488
171
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also posted at https://stackoverflow.com/questions/44402716/nosuchmethoderror-using-joss-api. Please read https://coderanch.com/wiki/660346/Forthright-Cross-Posting-Sites and act accordingly in the future.

HttpClient is indeed part of Android, as the error message says. Unless that 3rd party library uses the exact same version Android uses, there are bound to be problems (hence Gradle leaves out the library when packaging the app). Luckily, an approach for solving this is mentioned right there in the error message: "In case of problem, please repackage it with jarjar to change the class packages". That seems worth exploring.
 
Sai Sheela Pidatala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I apologise for posting same query at different sites, I am new to posting such queries. I will surely not repeat this in the future.
 
Everybody! Do the Funky Monkey! Like this tiny ad!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic