Muteeb Butt
Muteeb Butt

Reputation: 21

butterknife compiler error in android studio

"Cause: superclass access check failed: class butterknife.compiler.ButterKnifeProcessor$RScanner (in unnamed module @0x509fdebb) cannot access class com.sun.tools.javac.tree.TreeScanner (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.tree to unnamed module @0x509fdebb"

I imported a project which was built in jdk 11 enviroment on android studio. I am currently using android studio flaming with jdk 11.

when i researched about this error on internet and it gave me some solutions of making some module-info.java file. but i dont how to add this file on my project. also some solutions said to turn to jdk 11 which i did already. but still it didnt work out for me.

Upvotes: 2

Views: 6186

Answers (2)

peterKay
peterKay

Reputation: 19

I solved butterknife issue in Gradle 8.5 version like below. add the following code in your app/build.gradle => android {}

tasks.withType(JavaCompile).configureEach {
options.fork = true
options.forkOptions.jvmArgs += [
        '--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',

        '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED',
   ]
}

And add this line under to gradle.properties

android.nonFinalResIds=false

Upvotes: 0

Aashis
Aashis

Reputation: 91

It bugged my head and later I found the solution, it is in gradle use the JDK version 11 instead of 16. I was using JDK16, which causes the error. When I modified to JDK 11, it all started working fine.

Upvotes: 1

Related Questions