user5182503
user5182503

Reputation:

Gradle - could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory

I try to build my "Hello World" application with Android Studio and can't do it because of some problem with gradle. This is what I have:

$java -version
java version “1.8.0_151”
Java™ SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot™ 64-Bit Server VM (build 25.151-b12, mixed mode)

$ gradle -v

Gradle 6.5.1

Build time: 2020-06-30 06:32:47 UTC
Revision: 66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant™ version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_151 (Oracle Corporation 25.151-b12)
OS: Linux 4.9.0-6-amd64 amd64

This is gradle file generated by Android Studio

$ cat build.gradle
buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
   classpath “com.android.tools.build:gradle:4.0.1”
  }
}

allprojects {
  repositories {
     google()
     jcenter()
  }
}

task clean(type: Delete) {
   delete rootProject.buildDir
}

And this is the result:

$ gradle --stacktrace
FAILURE: Build failed with an exception.

    What went wrong:
    Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory

    Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    Exception is:
    java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory
    at org.gradle.internal.resource.transport.http.HttpClientConfigurer.configureSslSocketConnectionFactory(HttpClientConfigurer.java:122)
    at org.gradle.internal.resource.transport.http.HttpClientConfigurer.configure(HttpClientConfigurer.java:107)
    at org.gradle.internal.resource.transport.http.HttpClientHelper.getClient(HttpClientHelper.java:195)
    at org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:141)

Could anyone help me to solve this problem? These are my first steps with gradle and I have no idea what to do. If the problem is with dependency, then why this dependency is not included in gradle. Please, help.

Upvotes: 0

Views: 1680

Answers (1)

user5182503
user5182503

Reputation:

I solved the problem by using OpenJDK instead of Oracle JDK.

Upvotes: 1

Related Questions