How to use .jar file in .java files in Xamarin studio

  1. I want to make an Vimeo Client app for Android in Xamarin Studio

  2. So i create a new Android project

3.Then from developer vimeo i download java file basically API from https://developer.vimeo.com/api/libraries
then i study how to use these .java file in xamarin android project after searching a while i got just import them and from properties panel mark them as java Resources file
4. i does the same but then i tried to build my project so it gives these error means swiggles on these entries

import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.entity.ContentType; import org.apache.http.client.methods.HttpPatch;

After searching for a while i find that it basically some dependencies problem so i download the pakage which is basically in .jar format from http://www.java2s.com/Code/Jar/h/Downloadhttpclient42jar.htm So i read the documentation how to use jar files then i create a binding project as document said but not resolving these swiggles or dependencies .

If there is a better way suggest me .

Posts

  • la.tanblala.tanbla USMember ✭✭

    Correct me if I am wrong, but Xamarin is not meant to develop Android apps in Java. It allows a user to code Android apps in C#. The code you posted above is Java. If you would like to make a Java class or JAR available to C#, say so and we can help you with that. Otherwise, if you want to develop for Android using Java I would recommend another IDE, like Android Studio.

  • mobinyaqoobmobinyaqoob PKMember ✭✭

    I'm not sure about it , is it works or not because i not tried yet but after some googling i reach to this issue

    http://www.itexico.com/blog/bid/98568/Xamarin-Mobile-Development-Consuming-Java-Libraries-from-C-in-Xamarin-Android-Part-2

    Have a look at this link :)

  • la.tanblala.tanbla USMember ✭✭

    So it looks like you want to create a binding library. To do that create a new android binding library project in Xamarin Studio. Add the vimeo library jar to the Jars folder. Right click it and set the build action to InputJar. Build the project and assuming no errors a DLL will be produced that you can use with your other xamarin projects.

  • mobinyaqoobmobinyaqoob PKMember ✭✭

    @la.tanbla i understand your opinion but that's not what i want. i try to explain again in step
    1. i create a android project
    2.go to vimeo developer page and download un official java libraries which are three files which extention .java
    https://developer.vimeo.com/api/libraries
    3.to use these files i read the how to use .java in xamarin i got this
    https://www.committedcoder.com/using-android-java-libraries-with-xamarin-pt-1.html
    so i follow this.
    4.Now its time to build the project but i fails to say that
    "Error : package org.apache.http does not exist import org.apache.http.Header;"
    Not What when i double click on this error in VS it goes to this line in file
    import org.apache.http.Header; in Vimeo.java
    but if i try to write the line again it give me autocorrect complition
    import org.All Thing.All thing.All thing == so i select this import org.apache.http.Header;

  • la.tanblala.tanbla USMember ✭✭

    Try adding org.apache.http.legacy.jar as a reference jar to the project. You can find it in the AppData\Local\Android\sdk\platforms(your android platform)\optional folder.

  • mobinyaqoobmobinyaqoob PKMember ✭✭

    .java directly not use as an embeded Jar file because .java file is the source code and you should need .jar file to use it so if the .java file is not have any dependencies then just convert it from javac command prompt or google it how to convert java to jar through cmd.
    But if you have dependencies like in my case i use org.apache.http.annotation so for that purposes i open them in netbeans and solve all dependencies and then convert the project as fat jar.
    After converting to fat jar i create a binding library project in xamarin studio and add that jar
    So

  • mobinyaqoobmobinyaqoob PKMember ✭✭

    Now it said :
    Couldn't load class org/apache/http/client/protocol/HttpClientContext : java.lang.NoClassDefFoundError: org/apache/http/protocol/HttpCoreContext (J2X9001) (VimeoWithAllReferece)
    Couldn't load class org/apache/http/impl/conn/DefaultHttpResponseParserFactory : java.lang.NoClassDefFoundError: org/apache/http/io/HttpMessageParserFactory (J2X9001) (VimeoWithAllReferece)
    Couldn't load class org/apache/http/impl/conn/ManagedHttpClientConnectionImpl : java.lang.NoClassDefFoundError: org/apache/http/impl/DefaultBHttpClientConnection (J2X9001) (VimeoWithAllReferece)
    missing class error was raised while reflecting org.apache.http.impl.auth.HttpAuthenticator : org/apache/commons/logging/Log (J2XA006) (VimeoWithAllReferece)

    And these types of 60 errors ecours .

  • mobinyaqoobmobinyaqoob PKMember ✭✭

    And here is my Build Output

Sign In or Register to comment.