termux / termux-api

Termux add-on app which exposes device functionality as API to command line programs.
https://f-droid.org/en/packages/com.termux.api/
2.25k stars 449 forks source link

Termux:API commands return `Native registration unable to find class 'com/android/icu/text/TimeZoneNamesNative'; aborting...` inside Proot on Galaxy A10 with Android 13 (LineageOS 20) #639

Closed cattokomo closed 10 months ago

cattokomo commented 10 months ago

Problem description

Every Termux:API commands (including non-packaged into termux-api, like termux-open) returns an output:

Native registration unable to find class 'com/android/icu/text/TimeZoneNamesNative'; aborting...

Even if the all required environmnet variables to have most Termux:API commands to work. (Sourcing /etc/profile.d/termux-proot.sh if rootfs installed using proot-distro)

Steps to reproduce

  1. exec pd login alpine --user urnaree
  2. Any commands that run the libexec Termux:API or am. Example: termux-toast hello

Expected behavior

Successfully run the command.

Additional information

Grimler91 commented 10 months ago

Looks like you are not binding /system, /data and /apex in alpine, so I guess those paths are unavailable?

cattokomo commented 10 months ago

Looks like you are not binding /system, /data and /apex in alpine, so I guess those paths are unavailable?

It's available.

😼 # urnaree@localhost : ~
0% ls / | grep -E "apex|data|system"
apex
data
system
TomJo2000 commented 10 months ago

Please be aware that parsing ls inside a script is inherently flawed and does not work for some weird, but valid, filename edge cases.

Generally it is preferable to use find or to loop over a directory directly, e.g.

for file in ./*; do
    : "$file" # stuff
done

For more detailed explanations and examples see: https://mywiki.wooledge.org/ParsingLs

sylirre commented 10 months ago

Most likely the issue present in this "Zsh script to patch Termux commands inside Proot".

@UrNightmaree Why do you need to patch something inside proot? Are environment variables not getting configured, so you need to setup them manually?

Bad DEX2OATBOOTCLASSPATH or BOOTCLASSPATH is a typical reason why some classes are missing.

cattokomo commented 10 months ago

Are environment variables not getting configured, so you need to setup them manually?

Technically, I'm not setting it up manually. Instead I copy the content of <rootfs>/etc/profile.d/termux-proot.sh due to the file isn't sourced by Zsh.

sylirre commented 10 months ago

I would suggest to look values of these variables in Termux and update them.

cattokomo commented 10 months ago

I replaced BOOTCLASSPATH and DEX2OATBOOTCLASSPATH variables, and it works fine now.