0

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.

3
  • Try openJDK 8 rather than oracle jdk - its probably not included in their jdk. make sure you have open jdk 1.8 for both java and javac. You can use sudo update-alternatives --config java[c] to configure once installed. Commented Jul 26, 2020 at 18:47
  • @MarkKeen Yes, moving to openJDK 8 helped. It is really strange that mature product doesn't run on oracle jdk. If you make an answer I will accept it. Commented Jul 26, 2020 at 19:50
  • @MarkKeen what exactly is not included? Commented Sep 16, 2021 at 21:39

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.