如何将okhttp库导入android studio?

2 android android-studio okhttp

我想将okhttp源代码(不是jar)作为模块导入android studio.有什么建议吗?谢谢 !

Aus*_*ice 11

除非您在应用中出于某种原因需要源代码,否则可以通过添加将其添加为库

implementation 'com.squareup.okhttp3:okhttp:3.10.0'
Run Code Online (Sandbox Code Playgroud)

到您的Gradle构建脚本


Gre*_* Li 6

将此行添加到您的模块级build.gradle脚本(非项目级):

dependencies {
    // ...
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
}
Run Code Online (Sandbox Code Playgroud)

然后单击右上角的构建图标(绿色斧头)。


how*_*ttl 2

他们的源代码可以在 Github 上找到: https: //github.com/square/okhttp

将其克隆到您的计算机,并将其导入到您的项目中。