https icon indicating copy to clipboard operation
https copied to clipboard

Android app crashes on HTTP response

Open sido420 opened this issue 4 years ago • 11 comments

I am not using SSL pinning or https endpoint. Here is my request object dump:

 url: "http://192.168.5.10:3001/api/user?mapp=1"
 method: "GET"
 useLegacy: "false"
allowLargeResponse: "true"
 timeout: "30"
 headers: {
 "content-type": "application/json",
  "authorization": "Bearer ayJ...................9fbqlT"
 }

I have tried with allowLargeResponse and useLegacy true/false.

I do see that request is received on the server and a response is generated as well. But, the app crashes and I cant seem to get anywhere after Https.request(requestBody) call.

Here is the crash error:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to start activity ComponentInfo{com.example/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap.
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap.
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
System.err:     at android.os.Looper.loop(Looper.java:223)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:7656)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
System.err: Caused by: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap.
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err:     at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:24)
System.err:     at android.app.Activity.performCreate(Activity.java:8000)
System.err:     at android.app.Activity.performCreate(Activity.java:7984)
System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
System.err:     ... 11 more

Environment details:

        "tns-android": {
            "version": "6.5.3"
        }

Relevant packages (more can be provided if needed)

"@nativescript/core": "^6.5.19",
"nativescript": "^6.7.8",
"nativescript-background-http": "^4.2.1",
"tns-core-modules": "^6.5.19"
...
"nativescript-https": "^2.1.0",
$ npx tns version
6.7.8

sido420 avatar Jan 19 '21 05:01 sido420

I have tried an http client with similar settings and do get a response successfully with the following response headers:

x-dns-prefetch-control:
off
x-frame-options:
SAMEORIGIN
strict-transport-security:
max-age=15552000; includeSubDomains
x-download-options:
noopen
x-content-type-options:
nosniff
x-xss-protection:
1; mode=block
content-type:
application/json; charset=utf-8
content-length:
2893
etag:
W/"b4d-uMuVJHGFfaYbnzFk8maanI90"
vary:
Accept-Encoding
date:
Tue, 19 Jan 2021 06:14:37 GMT
connection:
keep-alive

sido420 avatar Jan 19 '21 06:01 sido420

@sido420 your error is pretty clear "Error: Main entry is missing. App cannot be started. Verify app bootstrap." nothing to do with the plugin

farfromrefug avatar Jan 19 '21 08:01 farfromrefug

Main entry is very much there and app works fine if I disable the function that makes http requests.

sido420 avatar Jan 19 '21 15:01 sido420

@sido420 cant really help without more logs. Hard to see what s going on. THe build should be telling you more

farfromrefug avatar Jan 19 '21 16:01 farfromrefug

I copied and pasted the whole error message before the crash. Other than that there are no errors and webpack build is successful.

Webpack compilation complete. Watching for file changes.
Webpack build done!
Successfully transferred bundle.js on device L1731622.

Is there something else you specifically need?

sido420 avatar Jan 19 '21 21:01 sido420

Is there a debug option or hooks etc to read the response from server (if/when it arrives)? Also, if you direct me to the right file and lines, we can enable Android logging as well.

sido420 avatar Jan 20 '21 01:01 sido420

@sido420 dont copy like 3 lines. Copy the whole build logs from when you run the build command.

farfromrefug avatar Jan 20 '21 07:01 farfromrefug

were you able to fix this? i´m having the exact same problem at this moment, and previously it was working

japasanto avatar Jan 25 '21 12:01 japasanto

@farfromrefug cant fix it without more logs!

farfromrefug avatar Jan 25 '21 15:01 farfromrefug

Any update on this? I am having same issue. It works no problem on iOS

mastashake08 avatar Aug 20 '21 01:08 mastashake08

@mastashake08 you have to understand the error log has nothing to do with this plugin. The app crash on start. And it mostly is related to build/project setup. Without more details or logs clearly saying the error is with this plugin i cant do much more

farfromrefug avatar Aug 20 '21 11:08 farfromrefug