skip to Main Content

Building succeeds, but running on an emulator fails with this message in the console:

Cause: superclass access check failed: class butterknife.compiler.ButterKnifeProcessor$RScanner (in unnamed module @0x65e8e2f6) 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 @0x65e8e2f6

What I’ve tried: Removing Butterknife from Gradle, syncing, adding back, syncing again. Removing the Butterknife lib completely which doesn’t produce this error on-compile, but obviously fails to compile due to missing Butterknife.

My environment: Butterknife 10.2.3 Android Grade Plugin Version: 7.1.2 – Gradle Version: 7.2 – Android Studio Bumblebee

I’ve read that this error happens with other libraries in some rare cases that seem unrelated to mine and I still haven’t found a solution. I’m aware the Butterknife is deprecated and I should migrate to ViewBinding, but that’s a big task to convert this entire project to at the moment. Thanks!

6

Answers


  1. You should compile with a different jdk, I was compiling with a jdk which was too advanced. Reverting it to jdk11 solved it for me

    Login or Signup to reply.
  2. Please use JDK 11. though we are setting the Gradle JDK as jdk11 or correto 11, Android studio is not recognizing that.

    Solution:

    1. in your terminal type java --version to see it if is showing as JDK 11

    2. If the version is not JDK 11, then set the JAVA_HOME env variable export JAVA_HOME=/Users/${echo $USER}/documents/AndroidStudio.app/Contents/jre/Contents/Home

    3. in your terminal type java --version to see it if is showing as JDK 11.

    Login or Signup to reply.
  3. Using ideas from answers above and using Android Studio: File | Settings | Build, Execution, Deployment | Build Tools | Gradle.
    Gradle JDK -> Android Studio default JDK (version 11.0.13 …)

    On Windows, to build from terminal, also had to add

    JAVA_HOME=C:Program FilesAndroidAndroid Studiojre
    

    To the File | Settings | Terminal | Environment variables

    Login or Signup to reply.
  4. Deleting the folder .gradle from the folder C:UsersyourUser.gradle fixed the issue.

    Login or Signup to reply.
  5. I faced this issue just after updating android Studio to Android Studio Flamingo | 2022.2.1, my project was using embeded jdk, i fixed using simple steps

    1. https://www.oracle.com/pk/java/technologies/javase/jdk11-archive-downloads.html
    2. Download JDK 11 for your desired OS
    3. Install it
    4. Android Studio-> File -> Project Structure -> SDK Location -> Click on Gradle Settings (blue hightlighted text) -> Select the jdk 11 with 11.0 something version name from list
    5. Run The Project
    6. Boom! it’s works
    Login or Signup to reply.
  6. Some of the sun libraries needs to be made visible for the newer Java compilers. See this answer for more info. I added the following to our gradle.properties file and it fixed the problem. (We use Butterknife and Realm, and needed the below three packages added. (You might get away without "javac.code" for just Butterknife))

    org.gradle.jvmargs=-Xmx1920M 
    --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED 
    --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED 
    --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search