Nativescript-cli: Android tns debug, crashing when there is a response from server

Created on 30 Oct 2017  路  12Comments  路  Source: NativeScript/nativescript-cli

_From @shiv19 on October 27, 2017 17:6_

System.err: com.tns.NativeScriptException: 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_

bug debug android

Most helpful comment

Marking this as resolved, as per https://github.com/NativeScript/nativescript-cli/issues/3187#issuecomment-340750599

To get the latest android runtime changes run tns platform add [email protected] in your nativescript project.

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

All 12 comments

Hey @shiv19, what are the reproduction steps?

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

@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.

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.

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.

https://github.com/NativeScript/android-runtime/pull/873

Marking this as resolved, as per https://github.com/NativeScript/nativescript-cli/issues/3187#issuecomment-340750599

To get the latest android runtime changes run tns platform add [email protected] in your nativescript project.

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

Awesome! :)

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

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

@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 [email protected]

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

Was this page helpful?
0 / 5 - 0 ratings