Got Error When run ConfigEvaluator.preconfigured().forKotlin() on Android app Runtime
- Dominant language
- Java
- Stars
- 11.5k
- Forks
- 402
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 20
Description
I'm very excited to learn about Apple Pickle and I just following the documentation of [configuration for kotlin](https://pkl-lang.org/main/current/kotlin-binding/pkl-config-kotlin.html) and [example for config-kotlin](https://github.com/apple/pkl-jvm-examples/),
I have SoldierConfig at my resources.

This is my ``SoldierConfig.kt``
```
package example
import org.pkl.config.java.Config
import org.pkl.config.java.ConfigEvaluator
import org.pkl.config.kotlin.forKotlin
import org.pkl.config.kotlin.to
import org.pkl.core.ModuleSource
class SoldierConfig {
private val config: Config = ConfigEvaluator.preconfigured().forKotlin().use { evaluator ->
evaluator.evaluate(ModuleSource.modulePath("SoldierConfig.pkl"))
}
private val soldier = config.to()
fun getBandungConfig() : Soldier.SoldierRequirement? {
return soldier.soldierConfigs.getOrNull(0)
}
}
```
I call the class at MainActivity.kt, like this
```
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val soldierConfig = SoldierConfig()
val requirementBandung = soldierConfig.getBandungConfig()
println("reqBandung: minAge is "+requirementBandung?.minAge)
}
```
I'm successfull on code generation and run it at main() fun, but failed when access the config from the class in app with error
```
FATAL EXCEPTION: main
Process: id.visionplus.android.atv.stag, PID: 2366
java.lang.NoSuchMethodError: No static method of(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path; in class Ljava/nio/file/Path; or its super classes (declaration of 'java.nio.file.Path' appears in /system/framework/core-oj.jar)
at org.pkl.core.util.IoUtils.getPklHomeDir(IoUtils.java:164)
at org.pkl.core.util.IoUtils.getDefaultModuleCacheDir(IoUtils.java:169)
at org.pkl.core.EvaluatorBuilder.(EvaluatorBuilder.java:53)
at org.pkl.core.EvaluatorBuilder.preconfigured(EvaluatorBuilder.java:89)
at org.pkl.config.java.ConfigEvaluatorBuilder.preconfigured(ConfigEvaluatorBuilder.java:47)
at org.pkl.config.java.ConfigEvaluator.preconfigured(ConfigEvaluator.java:30)
at example.SoldierConfig.(SoldierConfig.kt:9)
at id.visionplus.android.atv.presentation.main.MainActivity.onCreate(MainActivity.kt:126)
at android.app.Activity.performCreate(Activity.java:7161)
at android.app.Activity.performCreate(Activity.java:7152)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3114)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1839)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6833)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:500)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
```
Please help me, what's wrong and how to solve it?
Contributor guide
Research direction
Start with SoldierConfig.kt and MainActivity.kt, then trace ConfigEvaluator.preconfigured() through EvaluatorBuilder and IoUtils.getPklHomeDir(), where the stack trace reports the failing Path.of call. Reproduce the runtime failure on Android and determine whether the Pkl runtime supports this environment; done means documenting a confirmed cause and an Android-compatible resolution or clear compatibility guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100