integrating maven dependency into android Eclipse project, no JAR file

296 Views Asked by At

Ok, so, I'm developing an app for the Amazon FireTV, so I have to use Eclipse.

I'm trying to use this socket.io Java client library: https://github.com/nkzawa/socket.io-client.java

at the bottom of this post, i included the installation instructions, which I'm not really sure how to make work with my existing Eclipse project (I'm new to maven). so from my understanding, do i just add a pom.xml file and a test folder? Then paste in their "maven central code" into the pom.xml? Will this cause any issues with the other code in my project? Or, can I just copy and paste all their SRC code into my project, since it's MIT licensed? I'd rather learn how to do this the proper way. The project is not in JAR format, so I was thinking maybe copying the folder structure into my project then using the Project Properties, Add Library option to connect to my code? Maybe?

Their installation instructions, (available in their readme.md):

The latest artifact is available on Maven Central. Add the following dependency to your pom.xml.

<dependencies>
  <dependency>
    <groupId>com.github.nkzawa</groupId>
    <artifactId>socket.io-client</artifactId>
    <version>0.3.0</version>
  </dependency>
</dependencies>

Or to install it manually, please refer dependencies to pom.xml. Add it as a gradle dependency for Android Studio, in build.gradle: compile 'com.github.nkzawa:socket.io-client:0.3.0'

2

There are 2 best solutions below

0
On BEST ANSWER

So, I learned that Maven Central has JAR files available for download. That way, you can just include them in your project via the Project Properties dependencies options. Without having to learn Maven.

0
On

You need to first understand how Maven works (and what pom.xml stands for). Maven is a tool that helps you automatically install dependencies (files need) for a given project. E.g if a project needs to process json files, it will need to "import" a json library which will then be a dependency for that project. When you add the dependency file above to your project, and run Maven install, it goes and fetches all the dependencies for your socket.io-client to work. Unfortunately, Maven does work very well in building android application projects and can be fairly complex to setup correctly (from my limited experience). I would advise that you manually download the jar dependencies and then add them to your android classpath if you are not keen on investing a lot of time learning to use Maven. To manually install the files .. you can create a default maven project (http://www.tech-recipes.com/rx/39279/create-a-new-maven-project-in-eclipse/) in eclipse, add the dependency file above to your pom.xml and run Maven-install. This will download the dependencies you need to your Maven local repository. You can then copy them from there to your android project.

Regarding installing the socket.io client you can find more on these steps here http://denvycom.com/blog/socket-io-java-android-without-maven/