Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @3ca6a01c
I took an android repo from github and build it successfullt.
But when I try to deploy it to my device it is giving above error.
I am using Android Studio Giraffe | 2022.3.1
My JAVA_HOME is C:Program FilesJavajdk-11
Earlier there was no JDK installed in laptop, saw online that, this problem might be because I am missing JDK 11 so installed it, expecting it to solve my problem but no results
2
Answers
Java.lang.reflect.InaccessibleObjectException is a common error when dealing with module-based access control introduced in Java 9 and later. This error occurs when your code attempts to access private fields or methods within Java modules that are not accessible due to module restrictions.
if your code relies on reflection to access private fields or methods, you can use the –add-opens option to open access to the relevant module. For example:
you should add –add-opens java.base/java.io=ALL-UNNAMED YourMainClass
at gradle.properties, just like this: