11

I am trying to integrate Twitter4j library into Android project through Android Studio. Though there are enough materials for integration through Eclipse, there are no materials for integration through Android Studio.

How to do the integration?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
Mat
  • 581
  • 3
  • 9
  • 23

2 Answers2

24

Just add compile 'org.twitter4j:twitter4j-core:4.0.2' to your /app/build.gradle dependencies. It should look like:

repositories { mavenCentral() }

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:19.+'
    compile 'org.twitter4j:twitter4j-core:4.0.2'
}
Andrew T.
  • 4,701
  • 8
  • 43
  • 62
Alexander Pavlov
  • 470
  • 2
  • 8
  • 14
  • 1
    These days, you might want to replace the `compile` configuration with an `implementation` one according to [gradle docs](https://docs.gradle.org/current/userguide/upgrading_version_5.html#changes_6.0). This means you would, for example, replace it with `implementation 'org.twitter4j:twitter4j-core:4.0.7'`. – sanitizedUser Nov 11 '20 at 19:03
0

If you have downloaded the zip file from their site.

  1. Extract the files.
  2. Get/copy the core jar file. As of my version I got it at twitter4j-4.0.4 > lib > twitter4j-core-4.0.4.jar
  3. Go to Android Studio and under the tab of project find the libs folder YourProjectname>app>libs.
  4. Paste the jar here, right click on on the jar and choose add as library.

Hope this helps