Skip to content

Android tns debug, crashing when there is a response from server #3187

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

Closed
NickIliev opened this issue Oct 30, 2017 · 12 comments
Closed

Android tns debug, crashing when there is a response from server #3187

NickIliev opened this issue Oct 30, 2017 · 12 comments
Assignees
Milestone

Comments

@NickIliev
Copy link
Contributor

From @shiv19 on October 27, 2017 17:6

System.err: Calling js method onComplete failed
System.err:
System.err: Error: Response not found for requestId = 2
System.err: File: "file:///data/data/com.anygofitness.anygopartner/files/app/tns_modules/tns-core-modules/debugger/debugger.js, line: 71, column: 27
System.err:
System.err: StackTrace:
System.err: 	Frame: function:'responseReceived', file:'', line: 71, column: 28
System.err: 	Frame: function:'onRequestComplete', file:'', line: 60, column: 33
System.err: 	Frame: function:'onComplete', file:'', line: 37, column: 13
System.err:
System.err: 	at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: 	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
System.err: 	at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:957)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:941)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:933)
System.err: 	at com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
System.err: 	at org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:585)
System.err: 	at org.nativescript.widgets.Async$Http$1$1.run(Async.java:486)
System.err: 	at android.os.Handler.handleCallback(Handler.java:751)
System.err: 	at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: 	at android.os.Looper.loop(Looper.java:154)
System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6119)
System.err: 	at java.lang.reflect.Method.invoke(Native Method)
System.err: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
ActivityManager: Process com.anygofitness.anygopartner (pid 5414) has died
ActivityManager: cleanUpApplicationRecord -- 5414
^CExecuting after-watch hook from /Users/shiv19/Work/AnyGo/apps/partner/hooks/after-watch/nativescript-dev-sass.js
Stopping sass watch

This part of the app works totally fine when not running in debug mode.
This could be an issue with the debugger

Copied from original issue: NativeScript/NativeScript#4996

@petekanev
Copy link
Contributor

Hey @shiv19, what are the reproduction steps?

@NickIliev
Copy link
Contributor Author

issue reproducible with this demo app.
Steps to reproduce:

  • clone and build the application.
  • execute a debug command (via VSCode or with 'tns debug android')
  • navigate to any page that makes HTTP request (no breakpoints needed0

@shiv19
Copy link
Member

shiv19 commented Oct 30, 2017

@NickIliev @Pip3r4o
Steps to recreate.
create a search bar (or really simply a button will do) that calls this method

exports.onSearchTap = function() {
    try {
        const PLACE_AUTOCOMPLETE_REQUEST_CODE = 1;
        const intent = new PlaceAutocomplete.IntentBuilder(
            PlaceAutocomplete.MODE_FULLSCREEN
        ).build(app.android.foregroundActivity);
        app.android.foregroundActivity.startActivityForResult(
            intent,
            PLACE_AUTOCOMPLETE_REQUEST_CODE
        );
    } catch (e) {
        console.dir(e);
        // TODO: Handle the error.
    }
};

this is the google place picker (google api has to be configured for this,
and these dependencies in the app.gradle

dependencies {
	compile 'com.google.android.gms:play-services:11.2.2'
  compile 'com.google.android.gms:play-services-places:11.2.2'
}

this in the manifest file

<meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="insert some google maps api key that has places API enabled"/>

)

now, handle the onActivityResult something like this

app.android.foregroundActivity.onActivityResult = function(
    requestCode,
    resultCode,
    intent
) {
    const PLACE_AUTOCOMPLETE_REQUEST_CODE = 1;
    if (requestCode === PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode === android.app.Activity.RESULT_OK) {
            const place = PlaceAutocomplete.getPlace(
                app.android.context,
                intent
            );

            const navigationEntry = {
                moduleName: <replace this with some page>, 
                animated: true,
                transition: {
                    name: "slide",
                    duration: 380,
                    curve: "easeIn"
                },
                context: {
                    lat: place.getLatLng().latitude,
                    lng: place.getLatLng().longitude
                }
            };
            frameModule.topmost().navigate(navigationEntry);
        } else if (resultCode === PlaceAutocomplete.RESULT_ERROR) {
            const status = PlaceAutocomplete.getStatus(
                app.android.context,
                intent
            );
            console.log(status.getStatusMessage());
        } else if (resultCode === android.app.Activity.RESULT_CANCELED) {
            // The user canceled the operation.
            console.log("User cancelled the operation");
        }
    }
};

use tns debug android

while the debugging console is open and socket connection is made,
click on search bar, type some address and select it.

which execution context reaches the onActivityResult, it will crash the app!

however, if the debugging console is not open, tns debug android will not crash the app.

@petekanev
Copy link
Contributor

I can confirm that there is indeed a problem originating from the network inspector implementation for Android.

The issue is reproducible with a hello world app and a simple network request.

I'll let you know when a fix is available either in the tns-core-modules or the android runtime.

@NickIliev
Copy link
Contributor Author

+1 reported via NativeScript/NativeScript#5009

@petekanev
Copy link
Contributor

petekanev commented Oct 31, 2017

We found the problem, and prepared a fix which should become available in @3.4.0-2017-10-31-1of the Android runtime later today.

NativeScript/android#873

@petekanev
Copy link
Contributor

petekanev commented Oct 31, 2017

Marking this as resolved, as per #3187 (comment)

To get the latest android runtime changes run tns platform add android@3.4.0-2017-10-31-1 in your nativescript project.

cc @TheOnlyMatt, @tbsf, @chernov-stas, @yclau

@petekanev petekanev reopened this Oct 31, 2017
@shiv19
Copy link
Member

shiv19 commented Oct 31, 2017

Awesome! :)

@jonasao
Copy link

jonasao commented Nov 7, 2017

This issue seems to have been fixed, looking forward to 3.4.0.

@TheOnlyMatt
Copy link

TheOnlyMatt commented Nov 8, 2017

Currently getting an error running tns platform add android@next :
cp: no such file or directory: node_modules/tns-android/framework/libs

There is indeed no libs folder in the framework directory

It worked last week, this is not working anymore even after a nativescript reinstall, platform remove etc

@petekanev
Copy link
Contributor

@TheOnlyMatt The @next uploaded today depends on changes in the nativescript@next package, therefore you have two options

  1. Update the CLI to the @next

or

  1. (Recommended) Download the previous @next-tagged package - tns platform add android@3.4.0-2017-10-31-1

@TheOnlyMatt
Copy link

Ok thank you, it works again !
I followed the second option

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

No branches or pull requests

7 participants