Skip to content

Can kscript used in Android project written in kotlin #411

Open

Description

@wisdomtl

I want to do this:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        kscript.eval("val x =3")
        val result = kscript.eval("x+2")
        Log.d("test", "onCreate: result=$result")
    }
}

can kscript achieve this?

thanks for reading my stupid question.

Activity

  1. aartiPl commented on Sep 25, 2023

    @aartiPl
    Collaborator

    Well, they are saying that there are no stupid questions. And I kind of agree with that :-D

    In the case of kscript, you can do something similar by calling KscriptHandler.handle() function. Please see at Kscript.kt and KscriptHandler.kt files. But please remember that currently, you need to have Kotlin compiler installed in the system, which is called internally by kscript. From that point of view, I think kscript is unsuitable for your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions