I am using retrofit-beta2 and i get the below crash from time to time. Am not sure what am i doing wrong. It would be great if someone could give me a hint on fixing the problem.
Fatal Exception: java.util.NoSuchElementException
at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:79)
at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:164)
at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:283)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
at com.squareup.okhttp.Call.getResponse(Call.java:286)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:204)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:232)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.access$100(Call.java:35)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:171)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
As said in this issue there is two possibilities:
OkHttp has a bug where we’re attempting to recover when we shouldn't
be because we’ve exhausted all of the available routes.
OkHttp has a bug where you’ve got a custom DNS implementation that
returned zero IP addresses for a host and we didn't reject that.
My suggestion is to use new versions of retrofit and okhttp, because Retrofit 2 is already in release.
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.squareup.retrofit2:retrofit:2.0.0'
Related
So I have a pretty robust android application and I want to add some code from a react-native only application in one activity. I've gone through the docs on the site and it turned out to be a lot more complicated to integrate a react-native app into an existing android native app. Among the may errors, this is the one I'm current stuck on, does anyone know where this comes from?
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoClassDefFoundError: com.facebook.react.CoreModulesPackage$1
at com.facebook.react.CoreModulesPackage.getNativeModules(CoreModulesPackage.java:96)
at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:71)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:97)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:950)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:880)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:104)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:218)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:197)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
It's currently fetching the bundle and it gets to 100 percent but then the activity crashes with the error output above about CoreModulesPackages.
It's been pretty frustrating trying to get this thing up and running, there seems to be a bunch of errors from many sides, I had to import react native manually through an aar since the version on maven is archaic(0.20), download okhttp web socket support, FLog and .so loader stuff. Among also having to exclude architecture specific code. If anyone knows of an easier way to integrate a RN app into an existing codebase, I'd really appreciate it.
I'm coming from the native side trying to understand this thing. I set up npm, bundle up the js before staring the server and then run my app. After which i forward to the proper 8081 port. If I'm doing the sequence of steps wrong then someone please correct me. It's been 3 days. Halp.
I encountered this same error in my react native app on Android 5.x devices -- no issues on 6 or 7.
The issue ceased to occur after I removed Fabric.io Crashlytics as a dependency from my app.
I got same error.
Probles has been solved by properly configuration of multidex for old android
In my case I forgot to inherit my application class from MultiDexApplication
I've updated from okhttp + retrofit to okhttp3 + retrofit2 but my app doesn't start cause of this Exception
FATAL EXCEPTION: EventThread
Process: appli.speaky.com, PID: 14705
java.lang.NoSuchMethodError: No virtual method setCallWebSocket(Lokhttp3/Call;)V in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/data/appli.example.com/files/instant-run/dex/slice-okhttp-3.6.0_29bb10e5f590229716bfa8daf196d09ea67f56a8-classes.dex)
at okhttp3.ws.WebSocketCall.enqueue(WebSocketCall.java:108)
at io.socket.engineio.client.transports.WebSocket.doOpen(WebSocket.java:84)
at io.socket.engineio.client.Transport$1.run(Transport.java:82)
at io.socket.thread.EventThread.exec(EventThread.java:55)
at io.socket.engineio.client.Transport.open(Transport.java:77)
at io.socket.engineio.client.Socket.probe(Socket.java:472)
at io.socket.engineio.client.Socket.onOpen(Socket.java:485)
at io.socket.engineio.client.Socket.onHandshake(Socket.java:526)
at io.socket.engineio.client.Socket.onPacket(Socket.java:499)
at io.socket.engineio.client.Socket.access$1000(Socket.java:31)
at io.socket.engineio.client.Socket$5.call(Socket.java:313)
at io.socket.emitter.Emitter.emit(Emitter.java:117)
at io.socket.engineio.client.Transport.onPacket(Transport.java:134)
at io.socket.engineio.client.transports.Polling.access$700(Polling.java:17)
at io.socket.engineio.client.transports.Polling$2.call(Polling.java:124)
at io.socket.engineio.parser.Parser.decodePayload(Parser.java:251)
at io.socket.engineio.client.transports.Polling._onData(Polling.java:134)
at io.socket.engineio.client.transports.Polling.onData(Polling.java:106)
at io.socket.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:111)
at io.socket.thread.EventThread$2.run(EventThread.java:80)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
I also had the same issue. The issue was I am using socket 0.8.0 which I think has conflict with OKHTTP websocket implem.
Upon upgrading to the latest version of socket.io
compile('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}
and also using the latest version of OKHTTP (no need to include okhttp-ws)
compile "com.squareup.okhttp3:okhttp:3.7.0"
compile "com.squareup.okhttp3:logging-interceptor:3.7.0"
my app is not crashing upon first load and it is connecting to sockets. Interceptor also has no conflict whatsoever and is logging as expected on logcat.
With this, there is no need to downgrade your version of okHTTP for which it has been the working solution in the past. :)
Hi there,I have the same issue just days ago(my app is a react-native) ,I just use the 3.4.1 version to replace the latest,and solved it!
compile "com.squareup.okhttp3:okhttp:3.4.1"
compile "com.squareup.okhttp3:logging-interceptor:3.4.1"
and I guess it is caused by the Retrofit2's okhttp lib
I had this issue after launching the Android Studio Profiler, even after closing the profiler. Had to restart Android Studio to fix it.
I had similar issue. Problem with my project was it was using okhttp-3.3.1 which do not have method setCallWebSocket.
Make sure you add correct version of okhttp in your gradle and the older version which does not have setCallWebSocket are not included elsewhere under your project libraries or dependencies.
Seeing the following stack on old versions of Android (4.3 and earlier):
Caused by: java.lang.IncompatibleClassChangeError: interface not implemented
at okhttp3.internal.Util.closeQuietly(Util.java:100)
at okhttp3.internal.connection.StreamAllocation.streamFailed(StreamAllocation.java:332)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.recover(RetryAndFollowUpInterceptor.java:209)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:132)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
at okhttp3.RealCall.execute(RealCall.java:63)
This seems to suggest an incompatibility between okhttp and Java 6, where java.net.Socket doesn't implement Closeable.
And the problem appears to occur primarily as a result of a failed stream. It was difficult to reproduce until we started calling this php page (borrowed from https://stackoverflow.com/a/141026/315702), which forces a stream failure on the client side:
<?php
ob_end_clean();
header("Connection: close");
ignore_user_abort(true); // just to be safe
ob_start();
echo('Text the user will see');
$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush(); // Strange behaviour, will not work
flush(); // Unless both are called !
sleep(30);
echo('Text user will never see');
?>
This appears to be a bug with the current okhttp 3.6.0-SNAPSHOT build. I filed a bug report on the okhttp github site. The exception is thrown when the connection closes unexpectedly. [Update: the bug was quickly fixed by replacing Closeable with Socket for backward compatibility with Java 6 in this pull request.]
In our case, the real heart of the problem was that we didn't mean to use okhttp 3.6.0-SNAPSHOT in the first place. In our build.gradle, we specified 3.4.1. It turned out one of our third-party libraries had a dependency on okhttp:+, which we discovered via the following gradle command:
./gradlew -q :app:dependencyInsight --dependency okhttp --configuration compile
Because of this, we were pulling in whatever happens to be the latest version of okhttp. In our case, the culprit library was the okhttp extension to exoplayer. By excluding the unwanted module dependency on okhttp:+, we were able to avoid loading 3.6.0-SNAPSHOT:
compile('com.google.android.exoplayer:extension-okhttp:r2.0.4') {
exclude module: 'okhttp'
}
I have a problem with using Volley. I'm trying to send request to site http://lawbite_api.codebnb.me but results differ from phone to phone (depends on Android version). For some reason on Android 6 all OK, but on Android 4.4 I'm getting java.net.UnknownHostException.
Here is stacktrace:
com.android.volley.NoConnectionError: java.net.UnknownHostException: http://lawbite_api.codebnb.me/api/login
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
Caused by: java.net.UnknownHostException: http://lawbite_api.codebnb.me/api/login
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:279)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
at com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:264)
at com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:234)
at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:107)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)
The simple answer is to not use an underscore in the subdomain part of the hostname. It's probably something to do with the hostname rules in Android 4.4 (and probably lower).
I don't think url will change as per API level in Volley. I have already use same URL for all devices with API greater than Android 4.4 and there is no issue regarding to URL there is something else. Please provide Volley request code
I am using Realm and my app crashes with the following traces and I don't get any idea to resolve this. This is the only stack strace that I see on the console. Nothing else :
FATAL EXCEPTION: OkHttp Dispatcher
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
at io.realm.RealmConfiguration.equals(RealmConfiguration.java:186)
at io.realm.RealmCache.validateConfiguration(RealmCache.java:217)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:103)
at io.realm.Realm.getInstance(Realm.java:213)
at io.realm.Realm.getInstance(Realm.java:176)
at testapp.WebClient.WebClientAPICalls$2.onResponse(WebClientAPICalls.java:74)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
This is the line 74: Realm realm = Realm.getInstance(context);
I am not sure what the exact reason is for this crashing. Any help in this regard is highly appreciated.
So just for the information to the people out here, as confirmed by # Christian Melchior, it was a bug with the latest version of realm 0.88.0.
Hence I had to rollback to the version 0.87.5 for now in order to resolve the issue.
Christian Melchior, who works at #Realm.io has also confirmed that they are releasing a fix for this bug as soon as possible and hence the latest version should be good to go.