Directly importing Kite JAR file in Android conflicts with existing dependencies.

I've been trying to import the kiteconnect.jar file into my Android project. I did the following steps,

1. Downloaded the jar file from GitHub.
2. Added the jar file as a library in my project.
3. In module level Gradle file inside dependencies block I'm importing the jar file as,

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/kiteconnect.jar')

After that I sync the Gradle files(happens successfully) and then when I try to build the project it gives a lot of duplicate class error like in the attached image.

I also tried to manually exclude the dependencies as mentioned in this stackoverflow answer, but that is also not working.

Here's the link to full stack trace of the error that comes while building the project.

  • tonystark
    tonystark edited November 2022
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation files('libs/kiteconnect.jar')
    Aren't these two lines doing the same thing?
  • abhijeet___1
    Removing either of them didn't seem to work. I ended up manually porting things to my android project inside a new library module which works fine.
  • ryandias
    Hi abhijeet, I am facing the same issue.
    What is tried was directly copying the kiteconnect source files for the java project to my android studio project which includes the kiteconnect folder, models folder and the ticker folder. I also copied the other librbay dependencies from the java project to my AS project. I still got errors with the super-csv library and 'import org.apache.commons.codec.digest.DigestUtils;'

    Can you please explain the steps in detail which helped you to get it working.?

    This issue should have been solved by the tech team as I feel more people will want to implement this in android.
  • ryandias
    @abhijeet___1 : Your solution is the only way to get the kiteconnect library to work. I too managed to manually port the library to the android studio project. It took a good number of frustrating hours but now that i llok at it, it is a simple fix if you keep your cool. I actually failed on the first attempt but after reading this thread, i was determined to get it to work. it does help that we had the java project so thet we could port the classes from the project but i still feel that the tech team should wotk on a library for android app development. I am going to delete my question regarding the same the solution is in this thread.
Sign In or Register to comment.