Skip to content

Commit 9c75476

Browse files
committed
fix(android): trying to fix kotlin crashes
1 parent 6c6ad71 commit 9c75476

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

plugin/platforms/android/java/com/nativescript/https/OkHttpResponse.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ public void run() {
456456
});
457457
thread.start();
458458
}
459-
459+
public static ResponseBody getBody(Response response) {
460+
return response.body();
461+
}
460462
public static int getStatusCode(Response response) {
461463
return response.code();
462464
}

src/request.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ export function createRequest(opts: HttpsRequestOptions, useLegacy: boolean = tr
492492
OkHttpResponse = com.nativescript.https.OkHttpResponse;
493493
}
494494
try {
495-
const responseBody = response.body();
495+
const responseBody = OkHttpResponse.getBody(response);
496496
const message = OkHttpResponse.getMessage(response);
497497
const statusCode = OkHttpResponse.getStatusCode(response);
498498
const getHeaders = function () {

src/typings/android.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ declare namespace com {
2222
toFile();
2323
toFileAsync(filePath: string, callback: OkHttpResponse.OkHttpResponseAsyncCallback);
2424

25+
static getBody(response: okhttp3.Response): okhttp3.ResponseBody;
2526
static getStatusCode(response: okhttp3.Response): number;
2627
static getMessage(response: okhttp3.Response): string;
2728
static getHeaders(response: okhttp3.Response): string;

0 commit comments

Comments
 (0)