user1272246
user1272246

Reputation:

How to import okhttp library to android studio?

I want to import okhttp source code (not jar) to android studio as a module. Any suggestions on that ? Thanks !

Upvotes: 11

Views: 44407

Answers (5)

Shubham Pandey
Shubham Pandey

Reputation: 219

Go to app level build.gradleand add

For older gradle

implementation 'com.squareup.okhttp3:okhttp:4.12.0'

For newer version add

implementation("com.squareup.okhttp3:okhttp:4.12.0")

Upvotes: 0

Austin Musice
Austin Musice

Reputation: 553

Unless you just need the source code for some reason in your app, you can just add it as a library by adding

implementation 'com.squareup.okhttp3:okhttp:4.12.0'

to your Gradle build script or

implementation("com.squareup.okhttp3:okhttp:4.12.0")

for kts.

Upvotes: 27

Grey Li
Grey Li

Reputation: 12772

Add this line to your Module level build.gradle script (Not project level):

dependencies {
    // ...
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
}

Then click the build icon (green axe) on top right corner.

Upvotes: 8

SteveYan
SteveYan

Reputation: 51

OkHttp is a java project, you can use idea rather than Android studio.

  1. open idea
  2. project → open → select pop.xml in project root directory
  3. wait for a while

Upvotes: 1

howettl
howettl

Reputation: 12518

Their source is available on Github: https://github.com/square/okhttp

Clone it to your machine, and import it into your project.

Upvotes: 2

Related Questions