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

[TNS 3.0] Android: Pressing ENTER key from hardware keyboard in TextView throws an exception #4123

Closed
PeterStaev opened this issue May 5, 2017 · 13 comments · Fixed by #4208

Comments

@PeterStaev
Copy link
Contributor

This was tested on stock android emulators API 23, inside a TextView widget if you press Enter key on the keybaord (which my guess emulates the press of an Enter key on a hardware keyboard on a real device) throws the below mentioned error. Problem is this line where the call to _onReturnPress() is which is not implemented by the TextView widget due to incorrect typings in the d.ts file of EditableTextBase

An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException:
Calling js method onEditorAction failed
TypeError: owner._onReturnPress is not a function
File: "file:///data/data/com.comforcare.hm4.caregiverapp/files/app/tns_modules/tns-core-modules/ui/editable-text-base/editable-text-base.js, line: 77, column: 22
StackTrace:
Frame: function:'EditTextListenersImpl.onEditorAction', file:'file:///data/data/com.comforcare.hm4.caregiverapp/files/app/tns_modules/tns-core-modules/ui/editable-text-base/editable-text-base.js', line: 77, column: 23
at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1021)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:903)
at com.tns.Runtime.callJSMethod(Runtime.java:890)
at com.tns.Runtime.callJSMethod(Runtime.java:874)
at com.tns.Runtime.callJSMethod(Runtime.java:866)
at com.tns.gen.java.lang.Object_frnal_ts_helpers_l58_c38__EditTextListenersImpl.onEditorAction(Object_frnal_ts_helpers_l58_c38__EditTextListenersImpl.java:45)
at android.widget.TextView.doKeyDown(TextView.java:6030)
at android.widget.TextView.onKeyDown(TextView.java:5911)
at android.view.KeyEvent.dispatch(KeyEvent.java:2640)
at android.view.View.dispatchKeyEvent(View.java:9234)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2395)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1727)
at android.app.Activity.dispatchKeyEvent(Activity.java:2725)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2310)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4127)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3820)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3981)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2253)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1874)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1865)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2230)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

@tsonevn
Copy link
Contributor

tsonevn commented May 5, 2017

Hi @PeterStaev,
Thank you for reporting the issue.
I tested this problem on my side and have to confirm that this is a real problem on Android when you press Enter key for the TextView.
We will do our best to provide a fix for this issue as soon as possible.
I am also attached sample project, which could be used for debugging.
Archive.zip

@tsonevn tsonevn added this to the 3.1 TBD milestone May 9, 2017
hshristov pushed a commit that referenced this issue May 16, 2017
…oesn’t throw exception when Return is pressed

Fix #4123
hshristov pushed a commit that referenced this issue May 17, 2017
…oesn’t throw exception when Return is pressed (#4208)

Fix #4123
@vakrilov vakrilov added ready for test TSC needs to test this and confirm against live production apps and automated test suites and removed backlog labels May 18, 2017
@vakrilov vakrilov reopened this May 18, 2017
@vakrilov vakrilov added done and removed ready for test TSC needs to test this and confirm against live production apps and automated test suites labels May 18, 2017
@dtopuzov dtopuzov modified the milestones: 3.0.1, 3.1 May 22, 2017
@dtopuzov
Copy link
Contributor

Fix will be released in 3.0.1 later this week.

@rrjohnson85
Copy link

I'm still seeing this issue; however, only when running in release mode (i.e. tns run android --emulator --release [...key store flags...]). When running in a non-release mode, the issue doesn't exist in my test.

Note I've tested on an emulator and on an actual device, both running Android 7.x.

@tsonevn
Copy link
Contributor

tsonevn commented May 31, 2017

Hi @rrjohnson85,
I tested this case while building the app for release on API level 25 and 19 and everything works as expected while using latest modules 3,0,1.
Make sure that you deleted platforms and node_modules folders before building the app.

@rrjohnson85
Copy link

@tsonevn - I've tried deleting the platforms and node_modules folders, made certain that I'm on 3.0.1, and still no luck. Would it matter that I'm using Angular/{N} and not just {N}?

@tsonevn
Copy link
Contributor

tsonevn commented Jun 1, 2017

Hi @rrjohnson85,
Ther should be no difference, whether you are building pure NativeScript project or NativeScript Angular 2 one. The fix should work on both as expected.
Could you send us sample project, which we could debug locally?

@rrjohnson85
Copy link

@tsonevn A sample can be found at https://github.com/rrjohnson85/ns-4123

After installing NPM dependencies, run npm run release.android to run the application in release mode on an emulator.

Once the application loads, give the TextView focus and try to add a new line in the TextView - the application crashes immediately in all of my tests.

@tsonevn
Copy link
Contributor

tsonevn commented Jun 1, 2017

Hi @rrjohnson85,
Could you upgrade the package.json dependencies in the project, while using the below-attached one and to rebuild the project?

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.test",
    "tns-android": {
      "version": "3.0.1"
    }
  },
  "dependencies": {
    "@angular/animations": "~4.1.0",
    "@angular/common": "~4.1.0",
    "@angular/compiler": "~4.1.0",
    "@angular/core": "~4.1.0",
    "@angular/forms": "~4.1.0",
    "@angular/http": "~4.1.0",
    "@angular/platform-browser": "~4.1.0",
    "@angular/router": "~4.1.0",
    "nativescript-angular": "~3.0.0",
    "nativescript-theme-core": "~1.0.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.3.0",
    "tns-core-modules": "~3.0.0",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "babel-traverse": "6.24.1",
    "babel-types": "6.24.1",
    "babylon": "6.17.2",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "~0.4.0",
    "typescript": "~2.2.1"
  }
}

Bear in mind to delete platforms and node_modules folders before a rebuild.

@rrjohnson85
Copy link

@tsonevn It seems to be working now, though I'm not exactly sure why. Do you know which dependencies were causing the problem?

@tsonevn
Copy link
Contributor

tsonevn commented Jun 5, 2017

Hi @rrjohnson85
Most probably this issue is related to the @angular dependencies, which in your project refers to version 4.0.0 instead of 4.1.0.

@GrEg00z
Copy link

GrEg00z commented Jun 6, 2017

The problem persist for me with exactly the same package.json content than @tsonevn, except for :

  • "babel-traverse": "6.4.5",
  • "babel-types": "6.4.5",
  • "babylon": "6.4.5"

But it seems to happen only on Samsung keyboard, not android keyboard.
For example on a Nexus 5X, every thing work as expected

Here is the crash report I get when I tape the "return" touch on a Samsung SM-G935F device :

Exception com.tns.NativeScriptException: Calling js method onEditorAction failed TypeError: owner._onReturnPress is not a function File: "file:///data/data/org.nativescript./files/app/tns_modules/tns-core-modules/ui/editable-text-base/editable-text-base.js, line: 77, column: 22 StackTrace: Frame: function:'EditTextListenersImpl.onEditorAction', file:'file:///data/data/org.nativescript./files/app/tns_modules/tns-core-modules/ui/editable-text-base/editable-text-base.js', line: 77, column: 23

@rrjohnson85
Copy link

@GrEg00z @tsonevn I tested on a Galaxy S8 and it seems to work fine for me.

@lock
Copy link

lock bot commented Aug 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants