Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android app crashes on HTTP response #77

Open
sido420 opened this issue Jan 19, 2021 · 11 comments
Open

Android app crashes on HTTP response #77

sido420 opened this issue Jan 19, 2021 · 11 comments

Comments

@sido420
Copy link

sido420 commented Jan 19, 2021

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
Copy link
Author

sido420 commented Jan 19, 2021

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

@farfromrefug
Copy link
Member

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

@sido420
Copy link
Author

sido420 commented Jan 19, 2021

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

@farfromrefug
Copy link
Member

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

@sido420
Copy link
Author

sido420 commented Jan 19, 2021

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
Copy link
Author

sido420 commented Jan 20, 2021

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.

@farfromrefug
Copy link
Member

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

@japasanto
Copy link

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

@farfromrefug
Copy link
Member

@farfromrefug cant fix it without more logs!

@mastashake08
Copy link

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

@farfromrefug
Copy link
Member

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants