How to build and run okhttp 3.10.0

I clone the code from https://github.com/square/okhttp

And I want to read the source code of 3.10.0 version.

But it could not compile successfully.

gongzelong:okhttp gongzelong$ git branch
  master
* parent-3.10.0
gongzelong:okhttp gongzelong$ mvn clean verify
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'build.plugins.plugin[org.apache.maven.plugins:maven-surefire-plugin].dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn.jdk8.version}'. @ com.squareup.okhttp3:parent:3.10.0, /Users/gongzelong/Android/okhttp/pom.xml, line 320, column 28
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.squareup.okhttp3:okhttp:3.10.0 (/Users/gongzelong/Android/okhttp/okhttp/pom.xml) has 1 error
[ERROR]     'build.plugins.plugin[org.apache.maven.plugins:maven-surefire-plugin].dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn.jdk8.version}'. @ com.squareup.okhttp3:parent:3.10.0, /Users/gongzelong/Android/okhttp/pom.xml, line 320, column 28
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

After adding the code which is in my answer, it could run 'mvn clean verify'

But IDEA shows error like this:

You can also add that library to a demo project, the in android studio changes it to Project folder. you can find it in the external libraries.

or you can download it, then use the VsCode editor to open it and read.

How to build and run okhttp 3.10.0, github.com/square/okhttp And I want to read the source code of 3.10.0 version. But it could not compile successfully. gongzelong:okhttp� OkHttp » 3.10.0. Square’s meticulous HTTP client for Java and Kotlin. License: Apache 2.0: Categories: HTTP Clients: Date (Feb 24, 2018) Files: pom (2 KB) jar (402

for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn.jdk8.version}'

in their build.gradle they have

def alpnBootVersion() {
def version = System.getProperty('alpn.boot.version')

if (version != null) {
  return version
}

They have probably added alpn.jdk8.version as a variable in their local gradle.properties. Change def version = System.getProperty('alpn.boot.version') with def version = 8.1.13 , and this should solve the problem.

How to build and run okhttp 3.10.0, But it could not compile successfully. gongzelong:okhttp gongzelong$ git branch master * parent-3.10.0 gongzelong:okhttp gongzelong$ mvn� Notes : There is still a test that failed that has been commented out line 212 in the BaseRequestTest.java. I cannot find out how to throw an IOException since calling twice response.body().string() does not throw an IOException anymore but just returns an empty string.

It is due to lack of alpn version regarding to my java version

gongzelong:okhttp gongzelong$ java -version java version "1.8.0_172" Java(TM) SE Runtime Environment (build 1.8.0_172-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)

So after I add the following codes in the file /Users/gongzelong/Android/okhttp/pom.xml

gongzelong:okhttp gongzelong$ git diff
diff --git a/pom.xml b/pom.xml
index 8b87c2038..274159c3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -620,5 +620,14 @@
         <alpn.jdk8.version>8.1.12.v20180117</alpn.jdk8.version>
       </properties>
     </profile>
+    <profile>
+      <id>alpn-when-jdk8_172</id>
+      <activation>
+        <jdk>1.8.0_172</jdk>
+      </activation>
+      <properties>
+        <alpn.jdk8.version>8.1.12.v20180117</alpn.jdk8.version>
+      </properties>
+    </profile>
   </profiles>
 </project>

It could run 'mvn clean verify' and 'mvn clean install'.

OkHttp, Using the new version 3.10.0 the build fails with the following message: - Information:Gradle tasks See https://github.com/square/okhttp/blob/� It happened to me, and I just to make sure all the version of the same dependency in the whole project is the same. If you use jar, please delete it and add it in the dependency in the build.gradle file. for me, it worked fine. and I get the release apk. I think the reason why this happened is because the project has duplicated file.

Version 3.10.0 error using Proguard on Android Studio � Issue , OkHttp 3.10.0 introduces a breaking change to the telemetry library found in together to host and review code, manage projects, and build software together. ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at� Solved: I have an application jar with the dependency okhttp 3.10.0, which has a dependency on okio 1.14.0. Spark2 client provides Okhttp 2.14.0 and

Update OkHttp to 3.10.0 for old telem library � Issue #726 � mapbox , OkHTTP is an open source project designed to be an efficient HTTP client. If you are using Maven or Gradle as build system you can simply add a use the Client to create a Call object and use the execute method. Square’s meticulous HTTP client for Java and Kotlin. License: Apache 2.0: Categories: HTTP Clients: Tags: http client: Used By: Central (71) Redhat GA (7) ICM (1)

Using the OkHttp library for HTTP requests - Tutorial, implementation 'com.squareup.okhttp3:okhttp:3.10.0'. Sync the .build() val call = client.newCall(request) call.enqueue(callback) return call }. Download okhttp.jar (3.10.0) Add to Project. 174 downloads. Artifact okhttp Group com.github.ljun20160606 Version 3.10.0 Last update 09. February 2018 Newest version Yes

Comments
  • I hope it'll help you : stackoverflow.com/a/55790149/9908240
  • @ViralPatel thanks, before adding the jar locally, I would prefer to find out why it could not find the jar. mvnrepository.com/artifact/org.mortbay.jetty.alpn/alpn-boot, it has 7.1.2.v20141202 alpn. But IDEA shows error.
  • please provide log or error message
  • @ViralPatel Regarding to the IDEA error, plz check the screenshot. I mean the error is shown in IDEA. 'mvn clean verify' works fine now after I did what I said in my answer.
  • How you can implement okhttp in Gradle?
  • It is an option, but why the problem occurs and how to fix it directly?
  • you can try isaaaaame answer. but the OkHttp is a pure library if you use the android studio open it, you have to use import module or add library method.
  • The codes you mentions belongs to the version 3.10.0? It seems that there are no such codes in 3.10.0
  • @FrancisBacon check their build.gradle, it was edited 8 days ago: github.com/square/okhttp/blob/master/build.gradle
  • What you mean is trying to build the latest source code of okhttp. But how to build 3.10.0 source codes?
  • as @Lenoarod said: "OkHttp is a pure library if you use the android studio open it, you have to use import module or add library method.". it's not meant to be build as a standalone project.
  • I opened in via IDEA, so I should compile the project using maven. And the CONTRIBUTE.MD said, it could run 'mvn clean verify' successfully.