Questions tagged [okio]

Okio is a library that complements java.io and java.nio to make it easier to access, store, and process data.

Filter by
Sorted by
Tagged with
0 votes
0 answers
41 views

okhttp3 - Exception in thread "main" java.lang.NoSuchFieldError: Companion

I tried using 3.x and 4.x versions of okhttp, however I am ended up with below exception Exception in thread "main" java.lang.NoSuchFieldError: Companion at okhttp3.internal.Util.<...
0 votes
0 answers
81 views

org.apache.hadoop/hadoop-client-api always including com.squareup.okio 1.6.0 version

We have a CVE reported CVE-2023-3635 which requires the package com.squareup.okio_okio to be upgraded to 3.4.0. I have explicitly pinned this version in pom.xml ex: <dependency> ...
0 votes
1 answer
395 views

Are Retrofit and Okhttp abandoned?

Retrofit Version 2.9.0 (2020-05-20) Okhttp Version 4.10.0 (2022-06-12) Version 5.0.0-alpha.11 (2022-12-24) Retrofit has 36 opened pull request and 147 opened bug, Okhttp 9 opened pull request and 161 ...
10 votes
0 answers
581 views

How to read file with okio inside commanMain module in a Kotlin Multiplatform Project?

I am trying to read/write files in the commonMain module. I created a new Kotlin Multiplatform App for Android and iOS using the Android Studio Wizard. (New -> New Project ... -> Koltin ...
0 votes
1 answer
350 views

How do I check if a path is a directory using Okio?

I am using Okio in Kotlin/Native. How do I check if a path (for example /path/to/directory) denotes a directory? The scope of the check has to involve using the file system to check if the path ...
0 votes
2 answers
70 views

How to check if a path is inside another path using Okio?

I am using Okio in Kotlin/Native and I would like to check if one path is inside another path. Although there is a equal/greater than/less than operator, it looks like it only compares the length. ...
2 votes
2 answers
630 views

Okio native/multiplatform default paths

How do one access the common default paths using okio? The paths I'm specifically interested in are: Application directory (location of the executable(s) that are being run) Working directory (where ...
0 votes
0 answers
17 views

Okio and other issues [duplicate]

I am trying to execute this set of code but when I do I get these errors. I can't find anything on "okio" let alone how to fix the issue. See below for the list of the problems that show up ...
2 votes
3 answers
6k views

Testing OkHttp with MockWebServer and MockResponse with a Buffer body

I am trying to test some download code involving OkHttp3 and failing miserably. Goal: test downloading an image file and verify it worked. Platform: Android. This code is working in production but the ...
0 votes
0 answers
89 views

How to handle out of memory exception in okio sink?

I have a progress emitting request body.. class ProgressEmittingRequestBody( private val delegate: RequestBody, private val progressListener: ProgressListener, ) : RequestBody() { override ...
0 votes
1 answer
81 views

Can okhttp response body data be read after the call was cancelled?

In okhttp interceptor code, is it possible, after a call was cancelled, to read whatever partial response data might have been returned by the server? The end goal is to cache partial content so that ...
1 vote
1 answer
1k views

Access files in commonMain resources directory with OKIO - Kotlin Multiplatform

I wanted to include into my app (Kotlin Multiplatform Mobile) iOS + Android a .json file to be parsed and saved into Realm DB on the first launch using .initialData{}. I use expect/actual pattern and ...
1 vote
1 answer
498 views

Okio vs java.io performance

I read the following blog: https://medium.com/@jerzy.chalupski/a-closer-look-at-the-okio-library-90336e37261 It is said that" the Sinks and Sources are often connected into a pipe. Smart folks at ...
0 votes
1 answer
602 views

Okio source cannot be read inside a Kotlin Coroutine

I am trying to generate a Bitmap from an Okio source using this implementation val file = /* ... */ Okio.source(file).use { CoroutineScope(Dispatchers.IO).launch { Okio.buffer(source)....
0 votes
1 answer
431 views

How can I handle long response in OkHttp Java?

I am attempting to use okhttp-3.12.0 and okio-1.9.0 in my JAVA project to make POST call to a web service. I am able to successfully create the record, however, the web service returns a response of ...
3 votes
1 answer
321 views

Okio Throttler integration with OkHttp

My team is suffering from this issue with slack integration to upload files, so following the comments in that issue I would like to throttle the requests in our Kotlin implementation. I am trying to ...
2 votes
1 answer
421 views

Efficient mapping of byte buffers

I'm looking into the source code for Okio in order to understand efficient byte transferring better, and as a toy example made a little ForwardingSource which inverts individual bytes as they come ...
2 votes
1 answer
70 views

Does okio FileHandle have something similar to RandomAccessFile.getchannel() in java?

My problem is if the buffer is split, I want to make it contagious. In java, I used FileChannel for this purpose.
2 votes
4 answers
3k views

Spark and Influx: OKIO conflict

I'm running a job on Spark Yarn and trying to emit messages to Influx DB but I'm crashing on an okio conflict: 22:17:54 ERROR ApplicationMaster - User class threw exception: java.lang....
39 votes
5 answers
24k views

Tracking progress of multipart file upload using OKHTTP

I am trying to implement a a progress bar to indicate the progress of a multipart file upload. I have read from a comment on this answer - https://stackoverflow.com/a/24285633/1022454 that I have to ...
0 votes
1 answer
2k views

Okhttp3 jar missing okio?

I am trying to make a simple Java program to upload a bunch of images I have to imgur. But I am running into problem after problem and cannot just get okhttp to work. At this point the time I have ...
7 votes
4 answers
12k views

java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z

I am integrating Outlook API and for making HTTP Calls I am using Retrofit version 2.3.0 and okHttp3 version 3.9.1. However when I'm making an HTTP Call, for example : // Create a logging ...
1 vote
1 answer
181 views

Is it possible to run okio in javascript

I have query about okio , is it possible to run the okio in javascript, is there is any okio package available for javascript ? i got this query due to this commands in release notes of okio. Version ...
15 votes
2 answers
14k views

Download progress with RxJava, OkHttp and Okio in Android

In our app I download an image file with this code. I need to show download progress(downloaded bytes in percentage) on UI. How I can get download progress in this code? I searched for solution, but ...
16 votes
6 answers
16k views

kotlin/TypeCastException when trying to create OkHttpClient object

When i try to create a new OkHttpClient object an Exception get thrown I'm using OkHttp 3.11.0 and OkIO 2.0.0-RC1. Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/...
1 vote
1 answer
3k views

Writing file on Android with Okio

Hi All I'm reading raw audio from Android device and I want to write it into a file using Okio like this: BufferedSink sink = Okio.buffer(Okio.sink(file)); I have a callback to retrieve audio data, ...
8 votes
1 answer
3k views

How to configure Kotlin jvmTarget in a Multiplatform Android module?

I'm getting this build error: Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option Adding support for ...
13 votes
2 answers
9k views

Fatal Exception: java.lang.OutOfMemoryError using okhttp3 okio for download files

I have a App that downlaod content from the web. music, videos, pdfs.... like a download manager. But now its is crashing everytime is it downloading content: E/LVN/advanced_memory_manager.c: -------...
1 vote
2 answers
592 views

How to implement seek() function in BufferedSink (or BufferedSource) in OKHttp?

How to implement seek() function in BufferSink (or BufferedSource) in OKHttp? We all know that in Java, the RandomAccessFile class has a method seek(long), which enable us to start reading/writing a ...
0 votes
1 answer
1k views

How read a file in chunks correctly using Okio?

I'm trying to consume a file upload API that requires the file to be uploaded in chunks of a size in bytes that it specifies from a previous API call. So.... for example if the file is small it will ...
2 votes
1 answer
17k views

how to solve java.lang.NoClassDefFoundError: okio.Okio?

I have an app that work very well but some times when I add some class and code to my program my app crashes. In my logcat error is for this: 8871-8929/com.example.first E/AndroidRuntime﹕ FATAL ...
0 votes
1 answer
245 views

How to rollback/revert IO operations incase of exceptions during writing? - Java

Is it possible to roll back the current IO operation incase of any exceptions during writing? I'm trying to write a UTF-8 string to a file with Okio library using the below expression file.sink()....
13 votes
2 answers
13k views

Handling Authentication in Okhttp

I'm using OkHttp 2.3 with basic authentication requests, according to OKHttp docs, it automatically retries unauthenticated requests, but whenever I provide invalid credentials, the request takes too ...
10 votes
3 answers
3k views

Getting "source exhausted prematurely" when inflating gzip HTTP response body

I get this following error when I'm trying to make a HTTP call with okhttp: W/System.err: java.io.EOFException: source exhausted prematurely W/System.err: at okio.InflaterSource.read(...
11 votes
2 answers
4k views

How to fix: "Unresolved reference: buffer" or "Using 'buffer(Source): BufferedSource' is an error. moved to extension function"?

I had 3 line code to get body from OkHttp3 source: val responseBody = response.peekBody(response.body()!!.contentLength()) val source = GzipSource(responseBody.source()) val body = Okio.buffer(source)...
0 votes
1 answer
217 views

Cancel downloading a File with OkHttp3

I want to cancel downloaded File with Okio ,it runs in AsyncTaks When I cancel Asynctask downloadedFilerunTask.cancel() I can get rid of downlaoding process with using break, but downloaded process ...
0 votes
0 answers
317 views

When Downloading File Show ProgressBar in Okio

I downloaded file using OKHTTP3 library, and then I saved file to disk using Okio.buffer,but I want to show progressBar when downloading continously,how can I do this with Okio? try { ...
0 votes
0 answers
876 views

How to resolve Retrofit write from Timimg Out when POSTing large requests

My Android application has started failing as follows when POSTing large (17048 Bytes) API requests 2019-09-20 08:20:01.198 15645-15862/org.aaa.bbb.ccc.mycompany D/GraphqlNetworkControlle: mutation {"...
0 votes
0 answers
613 views

Downloading pdf with okhttp and okio

I'm facing some problems downloading pdf inside my app. Some pdfs cannot be opened, because of the following message (invalid format) Error = cannot create document: File not in PDF format or ...
3 votes
1 answer
3k views

Fail to run app using OkHttp on 'Android L' emulator

Our app uses latest version of OkHttp (2.0.0) + Okio (1.0.0) + Picasso (2.3.2) and I wanted to try it out on the new "Android L" emulator (Intel) and it gets installed but when loading the app i get ...
1 vote
1 answer
1k views

Efficient okio Source backed by an already allocated ByteString?

When using the OkHttp Websocket the listener uses a ByteString to provide the binary payload to the application. I want to feed these bytes into some code which takes a okio.Source (in this particular ...
0 votes
1 answer
275 views

How to make a post request using Okio?

I'm using Okio to download a file....with my request i'm sending some parameters, but since I wasn't getting my file and I was able to log my request and this is what is see: Why tags is null? that ...
0 votes
1 answer
613 views

Okio's BufferedSource request() only fires once

I'm downloading a file using a Retrofit2 implementation of a REST API, per the nice tutorial at https://futurestud.io/tutorials/retrofit-2-how-to-download-files-from-server. My API interface declares ...
1 vote
0 answers
189 views

BadPaddingException: pad block corrupted while trying to decode

I'm facing with BadPaddingException while I'm trying to decode InputStream. I was able to encode/decode OutputStream/InputStream while I'm using jackson but when I tried to do with Okio it throws ...
2 votes
1 answer
1k views

Convert OutputStream to Okio Source

I am trying to find elegant way to convert OutputStream produced by bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream) method to Okio's Source / InputStream (needed to further manipulate data -...
0 votes
1 answer
299 views

How to decode a http request packet with okio/okhttp

Can I use Okio and/or OkHTTP to decode a packet read from ParcelFileDescriptor ? I'm trying to write a VpnService based ad-blocker on android. I've found a few open source projects using VpnService ...
1 vote
0 answers
298 views

can't find referenced class issue?

We are using shopify Android buy sdk to develop this app compile 'com.shopify.mobilebuysdk:buy3:3.1.1' compile 'com.shopify.mobilebuysdk:buy3-pay-support:1.0.2' Error and Warning warning: com....
3 votes
0 answers
4k views

Cannot resolve okhttp request.builder()

I have added my maven dependency as in my pom.xml file. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven....
0 votes
0 answers
783 views

How do I import ok.io into android studio locally?

I have been trying to use ok.io, (version 1.14.1), locally in my project and it's been quite a struggle getting through the gradle requirements. My project requires that I include the source locally. ...
0 votes
0 answers
189 views

IllegalArgumentException when running retrofit api unit test

I am getting the below IllegalArgumentException when trying to run my unit test: java.lang.IllegalArgumentException: in == null at okio.Okio.source(Okio.java:128) at okio.Okio.source(Okio.java:124) ...