From 90ceb6d6abb6ba57c42efed7fca7c4b06a1ddd6a Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Fri, 18 Sep 2026 19:24:34 +0200 Subject: [PATCH] Fix internal access error https://robolectric.org/getting-started/#running-with-java-17-and-higher --- app/build.gradle.kts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 57027c116..a498075dd 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -89,15 +89,34 @@ android { } } - // Starting with Android Studio 3 Robolectric is unable to find resources. - // The following allows it to find the resources. - testOptions.unitTests.isIncludeAndroidResources = true tasks.withType().configureEach { testLogging { events("started", "passed", "skipped", "failed") } } + testOptions { + unitTests { + // Starting with Android Studio 3 Robolectric is unable to find resources. + // The following allows it to find the resources. + isIncludeAndroidResources = true + all { + // Needed on Java 17 and up + it.jvmArgs( + "--add-opens=java.base/java.lang=ALL-UNNAMED", + "--add-opens=java.base/java.util=ALL-UNNAMED", + "--add-opens=java.base/java.io=ALL-UNNAMED", + "--add-opens=java.base/java.net=ALL-UNNAMED", + "--add-opens=java.base/java.security=ALL-UNNAMED", + "--add-opens=java.base/java.text=ALL-UNNAMED", + "--add-opens=java.base/jdk.internal.access=ALL-UNNAMED", + "--add-opens=java.desktop/java.awt.font=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + ) + } + } + } + lint { lintConfig = file("lint.xml") }