5

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?

n1nsa1d00
  • 856
  • 9
  • 23
Benni
  • 969
  • 1
  • 19
  • 29
  • How about you be more specific? Show us your exact build file, and exactly what's happening that shouldn't be happening. The build script should be called "build.gradle". it seems like you have a multiproject build. What is your directory structure? – David M. Karr May 08 '15 at 15:39
  • I put it in a pastebin since the format was messed up when I was trying to edit, http://pastebin.com/Ke1VL63j. I use libgdx framework so the structure splits into IOS, android ,core etc.. – Benni May 08 '15 at 15:44
  • SO's "code sample" format is awkward, so I can understand that. By providing this in pastebin, you've only dealt with my very first point. Respond to everything else. – David M. Karr May 08 '15 at 15:54
  • I can´t tell you what the directory structure is since I don´t know what that means, or more clearly I dont know how to explain? What´s not happening is that I can´t reach any of the classes that the twitter4j library provides. They can´t be resolved. – Benni May 08 '15 at 16:08
  • Update your posting with the exact console output that shows your build running and the error messages. Paste the output into a text editor and indent it all 4 spaces, and then paste the result into the "Code Sample" block in SO. – David M. Karr May 08 '15 at 16:13

2 Answers2

3

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 :)

Yuva Raj
  • 3,881
  • 1
  • 19
  • 30
2

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'
Nandan Desai
  • 397
  • 3
  • 10