Hi, can someone recommend me a library that can ex...
# android
a
Hi, can someone recommend me a library that can execute Javascript code in android outside webview?
g
Are you planning to use javascript code to use in android natively?
a
yes
I need to be able to call javascript functions from android application outside a webview
k
j
We package Duktape for Android: https://github.com/square/duktape-android/
đź‘Ť 2
đź‘€ 1
k
even better!
a
the issue with duktape is that it doesn’t support object data transfer
and the javascript will be common for both android and ios apps
and the ios team want’s to have this functionality
a
is duktape better than a plain headless webview
j
depends what you're doing. it's certainly less resource intensive.
o
the issue with duktape is that it doesn’t support object data transfer
Not sure what that means, but in our project we have following setup: duktape-android (thanks Square for a nice wrapper) on Android and JSCore on iOS. Original JS code is written in ES6 for Web, we transpile it to ES5 (duktape and JSCore before iOS 10 do not support ES6) and run it in native apps. We have built a bit more functionality on top of duktape-android, things like JsonObjectWrapper which reflectively converts between Kotlin classes and JSON, transparent JS<->Kotlin Promise support with coroutines and Deferred, a bit stricter memory deallocation, and convenient debugger attachment process. We plan to open source this small addon at some point. On iOS Safari connects to JSCore for debugging automatically. It works pretty good so far, so I can recommend this approach. Alternatively, either WebView or JSCore on both platforms.