Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile Twitter4j with gradle

I'm trying to use the twitter4j library. And I saw on their website that you can use Maven to integrate it.

So In my gradle.build file I did

buildscript {
repositories {
    mavenCentral()
jcenter()
}

and compile:

project(":core") {
apply plugin: "java"


dependencies {
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
    compile 'org.twitter4j:twitter4j-core:4.0.3'
  }
}

This doesn't seem to do the trick. I can't use any of the classes from twitter4j even after cleaning and refreshing everything. What I'm concerned about is that I downloaded the twitter4j-4.0.3.zip and extracted it , but I never placed the folder or it's content anywhere? Feels like i'm missing something?

like image 316
Benni Avatar asked May 08 '15 15:05

Benni


2 Answers

I faced this kind of issue few weeks back when i try to utilize Twitter4j library through Gradle.

What i did was,

  1. Downloaded the Twitter4J zip file from their site.
  2. Open the extracted folder and there you will find lib folder. Open it.
  3. You will find some .lib files like twitter4j-core-4.0.3.jar. This file core is important and you need to add remaining .jars when you use that application. If you're not sure, then copy all .jars and paste it in libs folder.

enter image description here

  1. Then click File -> Project Structure -> Select app in the left column -> choose Dependency Tab.
  2. Click + in right top and choose File Dependency then select the jars in libs folder.

enter image description here 6. Click Ok and you're done.

Good luck :)

like image 61
Yuva Raj Avatar answered Nov 15 '22 02:11

Yuva Raj


Even I faced the similar problem recently and adding it like this to the gradle dependencies seems to work for me:

compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.7'
like image 2
Nandan Desai Avatar answered Nov 15 '22 01:11

Nandan Desai