#Typescript Completions (like VSCode) on Android

1 messages ยท Page 1 of 1 (latest)

teal crypt
#

Download Apps

  1. Termux: Download from here or here.
  2. Acode: Get it from the Play Store.

Setup Termux

  1. Open Termux and run these commands to update and initialize it:
pkg up -y && termux-setup-storage && pkg install nodejs-lts 
npm install -g acode-lsp ts-loader typescript typescript-language-server

Set Up Acode

  1. Open Acode and install these three plugins:
  • Eruda Acode
  • Acode Language Client
  • Typescript Language Client

Usage

  1. To access your phone's storage from Termux, change the directory by running:
cd /sdcard/ && touch undefined && pwd
  1. Create and open the "Acode" folder on your main storage with:
mkdir -p Acode && cd Acode
  1. Download the latest stable Minecraft typings by running:
npm install @minecraft/server @minecraft/server-ui
  1. Open the same folder in Acode and create a test js file.

  2. Start the server (LSP) in Termux by running:

acode-ls

You will start to see auto-completions for Minecraft typings.

Version info i tested with

Android 12 or 10

  • Apps

    • Termux v0.118.0
    • Acode v1.10.3
  • Termux Package

    • Node v20.13.1
  • NPM packages

    • acode-lsp v1.0.6
    • ts-loader v9.5.1
    • typescript-language-server v4.3.3
    • typescript v5.5.3

Showcase video: Youtube

#

Here you go @prime thistle @regal wasp @peak zinc @sick hawk

prime thistle
#

๐Ÿ”ฅ

peak zinc
#

oh

#

i need to root my phone, dont i

teal crypt
#

nope

peak zinc
prime thistle
#

to update typing i just have to run npm command right?

teal crypt
#

yes

#

with cd /sdcard/ you can locate main storage then you can visit your folder to install your npm ver

prime thistle
#

@tranquil fable

#

@gray dove

regal wasp
#

Amazing, thank you for making this

forest saddle
#

What about Js completion

gray dove
#

funny enough I recently downloaded termux

sick hawk
#

its neat!

cobalt sleet
#

Nice

gray dove
teal crypt
#

show full

gray dove
teal crypt
#

show acode logs, click floating settings icon

gray dove
#

acode has logs?

gray dove
teal crypt
#

you followed all the steps with success ?

gray dove
teal crypt
#

what you did list from start

gray dove
ionic meadow
#

I have the same error and did carefully followed the steps ๐Ÿ˜ฆ

teal crypt
#

i want to to knwo the exact steps you guys did to find issue

gray dove
ionic meadow
#

Navigate to a folder : install @minecraft/server and @minecraft/server-ui.
Start acode-ls
Open a test.js file in Acode (in the same directory as node_modules).
Start typing

From there the error keep spamming

teal crypt
#

after running this do u see like this without errors ?

ionic meadow
#

Yes. The errors start after I begin to type in the js file

gray dove
ionic meadow
#

Yes

#

Note that node version is on v20.15.1 and not v20.13 as WavePlayz have

teal crypt
#

start server then open app and send the first few errors

ionic meadow
#

There is no error if I don't type

gray dove
#

how do I start server

#

mine happens regardless

ionic meadow
#

Yes my bad me too

teal crypt
#

first ones

#

the info realted to that would be on top

gray dove
ionic meadow
#

These are the only errors

gray dove
#

do i need to repeat the process from the top

ionic meadow
#

You start the server by starting acode-ls

teal crypt
#

scroll up on that console to see errors

ionic meadow
#

I'll redo to check

gray dove
#

my Termux is back to normal, not inside the Acode directory anymore

ionic meadow
#

Yes it doesn't matter I think

teal crypt
#

yea

gray dove
#

when I type acode-ls nothing happens

ionic meadow
#

These are the only errors
Do you want to see the network tab ?

teal crypt
#

minimize the console and send pic

ionic meadow
teal crypt
#

yea so its not detecting typescript , run npm list - g in termux and send pic

ionic meadow
gray dove
gray dove
ionic meadow
#

My directory is in /sdcard/Acode/Minecraft/heads so I do :
cd /sdcard/Acode/Minecraft/heads

teal crypt
#

you are in that directory

#

let me try on other phone

gray dove
ionic meadow
#

But you have to adapt to your directories structure

teal crypt
#

works fine on other phone as well

ionic meadow
#

๐Ÿ˜ญ

#

What's your node version ?

teal crypt
#

lets start from scratch, delete acode data

gray dove
#

at this point you guys have lost me

teal crypt
#

and do as i say

ionic meadow
#

Ok

gray dove
ionic meadow
teal crypt
#

first clear the acode app data from phone's app settings

gray dove
#

done

ionic meadow
#

Done

teal crypt
#

run this

pkg up -y && termux-setup-storage && pkg install nodejs-lts

and send full screen shot once done

#

as you already installed it it wont take time

ionic meadow
teal crypt
#

next run this and then send screen shot
npm install -g acode-lsp ts-loader typescript typescript-language-server

ionic meadow
teal crypt
#

now run run this

touch /sdcard/undefined

#

then this

mkdir -p Acode && cd Acode

ionic meadow
teal crypt
#

mkdir -p Acode && cd Acode
npm install @minecraft/server @minecraft/server-ui

#

now Open Acode app for the first time allow all perms, and install these in seq

  • Eruda Acode
  • Acode Language Client
  • Typescript Language Client

create a test.js file

start the server in termux with

acode-ls

close and reopen the acode app

gray dove
teal crypt
#

if you see "typescript" here then your done,

gray dove
ionic meadow
teal crypt
#

you started server ?

ionic meadow
teal crypt
#

on top it says using typescript means its now detecting it, some thing iis wrong with your network

gray dove
ionic meadow
#

Sorry I have to go

#

Thank you so much

teal crypt
#

something is blocking you from hosting the server

gray dove
teal crypt
#

yea issue seems to be about server, its failing to host it

#

which android version you have

gray dove
teal crypt
gray dove
#

hmm, it was too good to be true ๐Ÿ˜ž

teal crypt
teal crypt
wind turtle
#

@teal crypt hey i installed it properly and im on step 4, where is the folder located?

teal crypt
#

Phone Storage/Acode

wind turtle
#

Nevermind, found it thank you

teal crypt
#

let me know if it works

wind turtle
teal crypt
#

um?

wind turtle
teal crypt
#

reopen acode

wind turtle
# teal crypt reopen acode

nevermind i forgot to reload acode, anyways do i always do all steps everytime or do i just do the last step

teal crypt
#

just acode-lsp needs to be done everytime, make as many projects you want under Acode/ folder it will work for every file so no need to install npms again and again,

if you need to update npms in future then you can locate Acode by

cd /sdcard/Acode

and install new types by

npm i @minecraft/server

wind turtle
teal crypt
#

nope termux and Acode both cant access Android/data folder

#

you can use 3rd app called Automate as watcher, where you see folder for changes and then copy its content to Android/data

ionic meadow
#

What version of node you are in ?

prime thistle
#

how can i check node version?

#

for me its works perfectly

#

idk why its not workin for ya guys

wind turtle
#

skill issue

wind turtle
gray dove
sharp bluff
ionic meadow
#

My conclusion is that this doesn't work on Android 14+
acode-ls / typescript-language-server doesn't seem able to start other process

#

Perhaps we have to change the install location of global node_modules. I'll try later

gray dove
sharp bluff
teal crypt
sharp bluff
#

ohhh okay, I thought you were bypassing Android/data with Automate with android 14, i misunderstood.

teal crypt
#

nah, as acode can't access data/ i suggested autoamate to do it but on android 12 i can access data/ with automate

cloud current
#

@teal crypt

#

not working

#

It worked when I first installed it, then it didn't work.

teal crypt
#

disable battery optimization i guess

ionic meadow
#

Just tried to install all the packages not in global and realized it will be the cause it's in the termux data space.

So I keep getting:

Connecting to auto client: typescript-language-server ["--stdio"]
file:///data/data/com.termux/files/home/mynpm/node_modules/typescript-language-server/lib/cli.mjs:22503
          throw new Error(`tsserver process has exited (exit code: ${exitCode}, signal: ${signal}). Stopping the server.`);
          ^

Error: tsserver process has exited (exit code: 1, signal: null). Stopping the server.
    at TsClient.onExit (file:///data/data/com.termux/files/home/mynpm/node_modules/typescript-language-server/lib/cli.mjs:22503:17)
    at file:///data/data/com.termux/files/home/mynpm/node_modules/typescript-language-server/lib/cli.mjs:19177:20
    at file:///data/data/com.termux/files/home/mynpm/node_modules/typescript-language-server/lib/cli.mjs:18368:46
    at Set.forEach (<anonymous>)
    at file:///data/data/com.termux/files/home/mynpm/node_modules/typescript-language-server/lib/cli.mjs:18368:26
    at file:///data/data/com.termux/files/home/mynpm/node_modules/typescript-language-server/lib/cli.mjs:18081:46
    at Set.forEach (<anonymous>)
    at ChildProcess.<anonymous> (file:///data/data/com.termux/files/home/mynpm/node_modules/typescript-language-server/lib/cli.mjs:18081:26)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)

Node.js v20.15.1
Closing process for 'typescript-language-serve
#

Battery optimization is disabled for me

cloud current
teal crypt
#

in phone settings > apps > termux > un restrict battey opt

cloud current
#

It didn't happen

teal crypt
cloud current
teal crypt
#

open console

#

u should see typescript on bottom

prime thistle
#

@teal crypt it does not shows me this kinda prompt for methods or anything and mind sharin your acode settings

teal crypt
#

show full sccreen shot

cloud current
teal crypt
#

executed every step successfully?

prime thistle
teal crypt
#

show logs, click on that floating icon

prime thistle
prime thistle
#

@teal crypt

teal crypt
#

restart then show logs

cloud current
#

Yes it worked at first then it didn't work

prime thistle
teal crypt
#

? said re start everything then show logs so that I can see the issue

teal crypt
#

what about termux

prime thistle
#

Server listening on port 3030
Connecting to auto client: typescript-language-server ["--stdio"]

teal crypt
#

everything seems fine to me maybe some other plugins creating issues

#

try to reset acode

prime thistle
#

yea it works fine now idk if it was because of that vscode theme

#

thx for ya help

gray dove
vagrant kestrel
#

I would definitely enjoy utilizing this if Google hadn't implemented Scope Storage, making it a pain to deal with Android/data for testing purposes.

sharp bluff
#

Yep, me too. I miss android 9, it was peak for me.

hot tartan
teal crypt
#

What regolith does ?

sharp bluff
#

i think it's a productivity tool for minecraft bedrock development like synchronizing target directory to com.mojang, automated lang stuffs, and more

teal crypt
#

well yeah u can use Automate for sync

hot tartan
hot tartan
teal crypt
#

yes

vagrant kestrel
# teal crypt use Automate

Not sure what that is, but if it's intended purpose is to gain access to that directory then I'm sure it will fail because of Scope Storage.

hot tartan
vagrant kestrel
hot tartan
vagrant kestrel
teal crypt
hot tartan
teal crypt
hot tartan
#

12

vagrant kestrel
#

Android 12 as well.

teal crypt
#

maybe you have newer patch thats why, i have oct 1 2022 android 12

#

which mostly works

#

as soon i saw the newes i disabled auto update ๐Ÿ˜›

vagrant kestrel
#

June 2023 on my end.

#

I wouldn't mind upgrading my device to something nicer, but can't push myself to do it because of the restrictions Google is implementing now. So I'm at that point in my life where I will upgrade when it's absolutely necessary. Otherwise, don't care.

I used to do a lot of mobile development for when I was on the go, but it's getting tougher these days. Too many obstacles lol.

teal crypt
#

i heard some apps can still access them if so it means workarounds still exists for devs

vagrant kestrel
#

If so it's because of a change in their manifest for permissions. Probably related to MANAGE_EXTERNAL_STORAGE which I believe introduced in Android 11. Google has a very strict policy for any published apps using it from my understanding.

#

Infact, could probably decompile a file manager app, include the permission, recompile, sign with a bogus signature, then install as a third party application lol.

#

@hot tartan you could try that ๐Ÿ˜œ

teal crypt
#

have you tried Wireless ADB

vagrant kestrel
#

I haven't, but I think ADB is restricted as well.

#

I'm tempted to try decompiling and modifying the manifest of one of these apps. I'm curious if it would work ๐Ÿค”

#

I haven't seen anything mentioned about it on xda.

teal crypt
#

Automate do have that that perm manifest otherwise it wouldnt be possible to access those folder even on my ver

vagrant kestrel
#

Hmm, interesting.

teal crypt
#

they fixed the trick used by these devs i guess

vagrant kestrel
#

Well I know there was another permission you could use in the manifest which was "legacy" but Google said it was only temporary to allow the devs to make adjustments then they were removing it. So that permission was probably how they worked around it until Google stopped it.

teal crypt
#

top devs might still have other tricks which they dont share to avoid patch

vagrant kestrel
#

That's understandable

#

I still don't understand why they don't allow us to grant access on the user level.

teal crypt
#

copying ios ig

vagrant kestrel
#

It would still provide "security" while putting liability on the user if they manually grant it.

vagrant kestrel
#

Never thought I would see those words.

teal crypt
#

with otg u can still access everything

hot tartan
#

yeah, the only ways i can access the Android/data folder are by connecting my phone to a pc using a USB cable and the other using shizuku to allow Zarchiver to access them

#

both methods are helpless for automated management of files.

#

i have made a nodejs script that replicates exactly what regolith does but i have no way to run it on the Android/data folder

hot tartan
vagrant kestrel
hot tartan
#

that's a pc app, i will give it a try when i get a new laptop

vagrant kestrel
#

Tested using the wireless debugging method via pairing and creating a proxy.

teal crypt
vagrant kestrel
# teal crypt like?

I just set it up, then used ZArchiver to access the files and folders in android/data. That was feasible, but making changes in there was not allowed. Guess it's a hit and miss with devices.

#

Couldn't even create a new file in there lol.

teal crypt
#

try termux

hot tartan
hot tartan
teal crypt
hot tartan
#

can you link a tutorial?

vagrant kestrel
teal crypt
#

@hot tartan

vagrant kestrel
# teal crypt

Looking at the directory isn't the issue I believe. Making changes to that path is where the problem comes in. Some seem to be able to do it, others can't. My guess is it may be in relation to how some of these ROM's are built by the OEM's.

#

๐Ÿคทโ€โ™‚๏ธ

teal crypt
#

i can even create files

vagrant kestrel
#

Rip

teal crypt
#

paste these files in termux, edit the rish file and replace PKG with com.termux

then u can run commands by

sh rish -c "<command>"

use /sdcard/ to work with android files

hot tartan
teal crypt
#

let me know

hot tartan
#

these are my files.

teal crypt
#

wats in run js

hot tartan
#

js code

teal crypt
#

show

hot tartan
# teal crypt show

it's valid js code but if you insist here it is: ```js
const fs = require("node:fs")
//Dangerous
const mc = "../Android/data/tempFolder/"
const spck = "Project/"

function get_folders(path) {
return fs.readdirSync(path, { withFileTypes: true })
.filter(item => item.isDirectory())
.map(item => item.name)
}
function copy() {
fs.cpSync(spck + "BP", mc + "dev_BP/" + "cosmos_bp", {recursive:true})
console.log("Copied BP")
fs.cpSync(spck + "RP", mc + "dev_RP/" + "cosmos_rp", {recursive:true})
console.log("Copied RP")
}
function clean(mc_path, spck_path) {
const folders = get_folders(mc_path)
fs.readdirSync(mc_path).forEach(item => {
const exists = fs.existsSync(spck_path + item)
const is_folder = folders.includes(item)
// clean the folder
if (exists && is_folder) clean(mc_path + item + '/', spck_path + item + '/')
// delete removed files and folders
if (!exists) fs.rmSync(mc_path + item,{recursive:true})
})
}

function run() {
//copy bp and rp
copy()
//delete removed files
clean(mc + "dev_BP/" + "cosmos_bp/", spck + "BP/")
console.log("Cleaned BP")
clean(mc + "dev_RP/" + "cosmos_rp/", spck + "RP/")
console.log("Cleaned RP")
}
run()
console.log("All Done")```

teal crypt
#

i dont see anywhere u used rish u doing sh rish -c node run.js?

hot tartan
teal crypt
#

write a bash script

hot tartan
#

what? why?

teal crypt
#

ur passing all the cmds to remote shell where node doesnt exist

#

u would need to work with bash script

hot tartan
teal crypt
#

ye

#

see cmds u can use in code by

sh rish -c "ls /system/bin/"

hot tartan
#

my script is almost ready, i did it without ever knowing bash, so naturally it took me a long time

teal crypt
#

what is it

gray dove
atomic violet
#

I didnt know I needed this lmao

teal crypt
#

๐Ÿค”

ionic meadow
#

I managed to make the lsp server works on my phone Android 14

1 - you have to use termux from the github page (as recommended on this post)

2- install termux-exec that fixes a problem with the shebangs links : https://github.com/termux/termux-exec/pull/24#issuecomment-1873059748

GitHub

This is change to work around the Android 10 R^W violation (execution of binary files are not allowed).
See the README for more information.
Helping with testing
Help to test this would be great! F...

forest saddle
#

Java script completion?

teal crypt
#

what?

#

@forest saddle

forest saddle
#

I mean it supports js ?

#

My bad

#

Dumb question

teal crypt
#

supports both

forest saddle
#

Sorry

teal crypt
forest saddle
#

So i need to download termux from the link

teal crypt
#

but its bit buggy, if you type and remove too fast it requires restart

forest saddle
#

Them download Acode from google play ?

teal crypt
#

yep

#

or find a free apk online, if you know you know

forest saddle
#

That s good

forest saddle
#

Thank u man i really appreciate that @teal crypt

forest saddle
#

The intellisense

#

Yes it works , but the description dosen't work

prime thistle
teal crypt
#

yea

forest saddle
#

It works fine then

#

Thank u

#

I have another question

#

@teal crypt

teal crypt
#

sure

forest saddle
#

So

#

When i type . , I don't get auto completion until i write a letter

#

Is that normal

teal crypt
#

you can use Ctrl+space

#

to show the list

forest saddle
#

Works with vscode too ?

teal crypt
#

yes

forest saddle
#

Thank u very much

teal crypt
#

this triggers with letters cant do much about it

forest saddle
#

Ok

#

What about the methods ?

teal crypt
#

?

#

which methods?

#

its should show everything like vscode

forest saddle
#

Nvm

#

It doesn't show
getTags , and addTags methods in player

teal crypt
#

how code

#

@forest saddle

forest saddle
#

No i mean

#

getTags dosen't have description

teal crypt
#

try with "acode lsp" plugin

forest saddle
prime thistle
#

@teal crypt typing stopped workin and this is what shown in termux if i press enter it just force close termux

prime thistle
teal crypt
#

ahh seems like you didnt disabled battery settings

#

@prime thistle

prime thistle
teal crypt
#

how you did it show

prime thistle
#

well i added termux and acode as whitelist with adb shell

dumpsys deviceidle whitelist +com.termux same for acode package and now its working fine

teal crypt
#

k

dense moat
#

it worked for the first time but when i closed both apps and it stopped so i tried to run it using cd /sdcard/ && touch undefined && pwd && cd Acode && acode-ls but when i went back to Acode it kept saying initilaizing typecsript language server... and the auto completion wasn't showing/working, im not really sure what's the problem here

forest saddle
#

Hey

#

The server got shutdown some times without any reason

#

Because i m not in termux app

#

How can i fix that ?

dense moat
#

oh, you too?

forest saddle
#

Yes

ionic meadow
#

Can you show the logs that appear in termux after the repeating "initializing typescript language server"

ionic meadow
gray dove
ionic meadow
#

Yes.
Do you still unable to make it work?
Which version of Android are you running?
Do you have a screenshot or text version of the eventual traceback of acode-ls ?

gray dove
#

how did you make yours work

ionic meadow
#

Since it worked for some people I had hopes. Then I tried to understand why acode-ls crash at initialization. I figured out that it comes from typescript-language-server/tsserver. Then I searched and stumbled upon posts talking about the shebangs I termux wasn't well linking (instruction in the first line of an executable file that tell the system where is to find node or python etc) then I find the bug report that gives a "fix".

#

From where you installed termux ? Play store or apk from GitHub?

#

Did try installing termux-exec?

ionic meadow
#

Ok I'll try to give a shorter answer (sorry I am not very fluent in english):
acode-ls was crashing at initialization because the the lsp server used by acode-ls couldn't be started. And this was fixed for me by installing termux-exec

gray dove
ionic meadow
#

In the last comment from the link I gave

#

You can try this before if you want :

termux-fix-shebang $(which typescript-language-server)
gray dove
#

one sec

ionic meadow
#
termux-fix-shebang $(which tsserver)
gray dove
#

do I install a new app called termux or do I do it in the termux I installed

ionic meadow
#

For me this wasn't working with termux from the play store

#

So I had to replace it with the termux from GitHub (link in the first post)

#

From where you installed termux ?

#

You can try the two command before eventually reinstalling termux

teal crypt
#

termux on playstore is dropped, also if it worked for the first time then everything is fine its just that somehow your termux is closing and unable to work in BG

ionic meadow
#

Oh I didn't know it already worked for ZaneTB

gray dove
#

to busy rn

gray dove
teal crypt
#

that's why added installation step

wise tide
#

@teal crypt you need to scroll all the way up add a link at bottom

glacial vault
#

you have pins

wise tide
#

what pins

wise tide
#

Stuck here

silk venture
#

You can't use the console while running one of those servers.

#

End cycle with control+Z

cunning tinsel
#

Hey guys the completion dosent work until I type something which key is used to recommend things

#

Hey guys is there any way to disable other completion and only have the things that's required in minecraft for example world."DomStringMap" isn't required

teal crypt
copper flicker
#

@teal crypt

#

How to fix it

#

Request initialize failed with message: ENOENT: no such file or directory, stat '/sdcard/undefined'

copper flicker
teal crypt
#

yea run this in termux

touch /sdcard/undefined
#

@zihaoooo

copper flicker
#

Okay

copper flicker
teal crypt
#

what do you mean by that ?

copper flicker
#

When not start the TS language server

#

Like this

acode-ls
teal crypt
#

oh, no. you will have to start the server everytime

copper flicker
#

Ok

copper flicker
teal crypt
#

you could write a boot script, which will auto start the server everytime the phone boots

teal crypt
copper flicker
#

I runned the command when started the server

teal crypt
#

check to see if the file exists, in filemanager

#

all you need is a file at the root level named undefined like this

copper flicker
#

If exist then not have error?

#

I deleted it...

teal crypt
#

keep it there

#

that somehow fix the issue

copper flicker
#

Ok

#

@teal crypt also have error when halfway I coding

#

The undefind file alr exist

#

Then what's the error

#

@teal crypt help me plz

teal crypt
#

Ignore errors if it works

copper flicker
#

Not working

copper flicker
#

Wait it seems like not error now ,but if have again I will tell U @teal crypt

copper flicker
#

It will stop sometimes @teal crypt

teal crypt
#

You will have to type slowly, otherwise it crashes the server

copper flicker
#

@teal crypt everytime this error throwed then autocompletion will not working

teal crypt
#

try restarting everything

copper flicker
copper flicker
#

@teal crypt how to solve it ,it always stops working and keep throwing error

teal crypt
#

There will be errors, no matter what, I have them too. So as long as it works don't care a bout it

#

It might be cuz of battery optimization. Try removing background restrictions for the Termux app

prime thistle
copper flicker
#

How to fix this memory problem

#

Or how to increase memory limit

teal crypt
#

I don't have any idea about that. None of us faced memory issues, i don't know why you are facing it

copper flicker
bright wedge
#

wht is this?

copper flicker
#

I can't use it now , although it does not have throw error but the autocompletion does not display

primal wind
#

Thanks, it works pretty well. Sometimes it doesn't auto-complete, but you just have to close and reopen the file.

sonic lava
#

what for iphone?

shut crag
shut crag
shut crag
teal crypt
shut crag
# teal crypt Works

just tried i miss writted.

But doesn't work, says "LPS UNKNOW (VERSION UNKNOW)" at the bottom, instead of the version used.

#

No errors on Eruda.

teal crypt
#

Hmm

ebon frigate
vagrant kestrel
#

Original Post: #1263468963694903336 message

chilly dew