termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

termux-toast crashes process

Open jingyu9575 opened this issue 5 years ago • 4 comments

Problem description Calling termux-toast will crash the process (Android 8.1, Resurrection Remix 6.2)

Steps to reproduce

  1. termux-toast abc
  2. Termux:API will stop working. Then any API command like termux-battery-status will hang and log "process is bad".

Expected behavior Showing a toast

Additional information

Post output of command termux-info.

Updatable packages:
All packages up to date
Subscribed repositories:
https://dl.bintray.com/grimler/science-packages-21 science/stable
https://dl.bintray.com/grimler/game-packages-21 games/stable
https://termux.net stable/main
https://termux.net stable/main
System information:
Linux localhost 4.4.169-Chihayafuru-v0.60 #1 SMP PREEMPT Sun Jan 13 16:15:40 UTC 2019 aarch64 Android
Termux-packages arch:
aarch64
Android version:
8.1.0
Device manufacturer:
HUAWEI
Device model:
FRD-AL00

If you are rooted or have access to adb then capture a logcat with logcat -d "*:W", from a adb or root shell.

--------- beginning of crash
06-24 15:37:33.696  6306  6306 E AndroidRuntime: FATAL EXCEPTION: main
06-24 15:37:33.696  6306  6306 E AndroidRuntime: Process: com.termux.api, PID: 6306
06-24 15:37:33.696  6306  6306 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setTint(int)' on a null object reference
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.termux.api.ToastAPI$1.lambda$writeResult$0$ToastAPI$1(ToastAPI.java:36)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.termux.api.-$$Lambda$ToastAPI$1$fiyVytqeopW7wtBFP8RqXEm_m7w.run(Unknown Source:12)06-24 15:37:33.696  6306  6306 E AndroidRuntime:
                                                        at android.os.Handler.handleCallback(Handler.java:790)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6499)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
06-24 15:37:33.696  6306  6306 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

I suggest adding checks for background and textView here.

jingyu9575 avatar Jun 24 '19 07:06 jingyu9575

Experiencing the same problem here. I'm running Android 10 (Resurrection Remix 8.6.3)

level323 avatar Nov 10 '21 22:11 level323

Hmm

mcmomin avatar Nov 26 '21 12:11 mcmomin

I am on android 10, and have same problem. in the logcat it shows, process is bad. Screenshot_20211128-095140762

Ahmedazim7804 avatar Nov 28 '21 04:11 Ahmedazim7804

I found a temporary solution, according to this, it could be fix by starting an activity of app (termux-api here). But as termux-api is not launchable app, you cannot run it from launcher instead you can run it with command "am start -n com.termux.api/.DialogActivity" in termux. and termux-api will start working.

Ahmedazim7804 avatar Nov 28 '21 05:11 Ahmedazim7804