question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to instantiate the client

See original GitHub issue

While trying to instantiate OkHttpClient as follows inside the MainActivity of android:

OkHttpClient client = new OkHttpClient();

Stacktrace :

java.lang.BootstrapMethodError: Exception from call site #5 bootstrap method
    at okhttp3.internal.Util.<clinit>(Util.java:87)
    at okhttp3.internal.Util.immutableList(Util.java:234)
    at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:127)
    at com.amazonaws.transcribestreaminghttpclient.MainActivity.<init>(MainActivity.java:28)
    at java.lang.Class.newInstance(Native Method)
    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)
    at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)

Happens only on 3.13.1. Works well on 3.12.1. Any insights?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

98reactions
JakeWhartoncommented, Feb 6, 2019

Per the release notes, OkHttp requires that you enable Java 8 in your builds to function as of 3.13 and newer. You can learn more about how to enable this at https://developer.android.com/studio/write/java8-support.

You need to add something like

android {
    compileOptions {
        targetCompatibility = "8"
        sourceCompatibility = "8"
    }
}

to your application build.gradle.

12reactions
eddexcommented, Mar 18, 2019

@CHENGCHANGHU make sure to do a Clean Project (Build > Clean Project) after you change the build.gradle file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to instantiate service in client app - Stack Overflow
For some reason I cannot instantiate the class nor access the namespace of WCF service references I add to my VS2010 project.
Read more >
Opening a project plan results in "Unable to instantiate ... - IBM
In the Eclipse client, connect to the project area · Navigate to Plans > All Plans · Right click on a plan and...
Read more >
Failed instantiate InitialContextFactory org.jboss.naming ...
This issue occurs when the required configuration in the JBoss standalone.xml file is completed. Solution.
Read more >
Unable to instantiate provider com.ning.http.client.providers ...
my default config. Five hundred (105) new asynchttpclient call me I get the following error. com.ning.http.client.AsyncHttpClient: Unable ...
Read more >
Database Extractors occasionally failed with "Unable to ...
Unable to instantiate class. ... "Unable to instantiate class 'Class name'! Reason: con=<Return code>" Here are samples from HANA DB, ... <Client No.> ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found