Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle 8.0 build issue #1686

Open
alexmirash opened this issue Apr 14, 2023 · 55 comments
Open

Gradle 8.0 build issue #1686

alexmirash opened this issue Apr 14, 2023 · 55 comments

Comments

@alexmirash
Copy link

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

@worksatfreelance
Copy link

i am also facing Same issue . Updated build version also

@koer1991
Copy link

I have same problem
in my guess
gradle 8.0 need jdk17
but butterknife is not surport jdk 17

@rbalajicse
Copy link

I am also facing the same issue. Not even running the project. Please fix it.

@pahadi777
Copy link

I am also facing the same issue with gradle 8.0. Can anyone please help me out ?

@mitulbharatchandra
Copy link

I am also facing issue with gradle 8.0 need jdk17

@jorrrdane
Copy link

jorrrdane commented Apr 18, 2023

same problem
but gradle 8.0 isn't the reason, 7.2.2 - still appears
appeared after update on Android Studio to Flamingo

@vladp
Copy link

vladp commented Apr 19, 2023

same problem but gradle 8.0 isn't the reason, 7.2.2 - still appears appeared after update on Android Studio to Flamingo

@jorrrdane I agree as well. It seems to be related to Flamingo upgrade. I just upgraded and run into this problem (Linux).

Android Studio Flamingo | 2022.2.1
Build #AI-222.4459.24.2221.9862592, built on March 31, 2023
Runtime version: 17.0.6+0-17.0.6b802.4-9586694 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.85-1-manjaro
GC: G1 Young Generation, G1 Old Generation
Memory: 3072M
Cores: 6
Registry:
    external.system.auto.import.disabled=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.instant.shutdown=false
    gradle.version.catalogs.dynamic.support=true

Non-Bundled Plugins:
    idea.plugin.protoeditor (222.4459.16)
    org.jetbrains.plugins.hocon (2022.1.0)
    com.github.adamwojszczyk.sepiaTheme (0.7.0)

Current Desktop: MATE

When I saw errors like this in the past, eventually they were related to the proguard.
But in my case, I am building debug, so proguard should not even be in the picture

@fish47
Copy link

fish47 commented Apr 19, 2023

I have upgraded a toy project to AGP 8.0 through a few walkarounds below

# <app/build.gradle>

# https://stackoverflow.com/questions/65380359/lomboks-access-to-jdk-compilers-internal-packages-incompatible-with-java-16

# enable internal JDK API access at runtime
tasks.withType(JavaCompile).configureEach {
    options.fork = true
    options.forkOptions.jvmArgs += [
        # essential for butterknife
        '--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',

        # if you need Glide or LomBok
        # these may not be the exact list, but it works for me
        '--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',
    ]
}
# <gradle.properties>

# https://developer.android.com/build/releases/gradle-plugin#default-changes

# @BindView requires a constant resource ID
android.nonFinalResIds=false

@keshavbhusal1
Copy link

keshavbhusal1 commented Apr 23, 2023

I am also facing this issue. please fix it as soon as possible @JakeWharton

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

@chenjia404
Copy link

go to Android Studio Preferences..., then Build, Execution, Deployment / Build Tools / Gradle, then set the Gradle JDK to be of some version 15

@dreamozilla
Copy link

I have same problem in my guess gradle 8.0 need jdk17 but butterknife is not surport jdk 17

same issue . need solution.

@dreamozilla
Copy link

Apr 25, 2023

can't. when use gradle 8, JDK version 17 at least

@wujun2081
Copy link

go to Android Studio Preferences..., then Build, Execution, Deployment / Build Tools / Gradle, then set the Gradle JDK to be of some version 15

Tested and effective

@mrfaa
Copy link

mrfaa commented May 10, 2023

Faced the same issue. With this seetings it is working for me:

gradle-wrapper.properties:
grafik

build.gradle (app):
grafik

build.gradle (project) dependencies:
grafik

JDK is 17.

@savelyevdm
Copy link

go to Android Studio Preferences..., then Build, Execution, Deployment / Build Tools / Gradle, then set the Gradle JDK to be of some version 15

Fix works if your gradle version is still under 8.0 (as it requires JDK 17 minimium).

@savelyevdm
Copy link

@JakeWharton If the library is discontinued in support - should we even hope for the update to support JDK 17 ?

@VectorWen
Copy link

use JDK15 can fixed.

@ShaFaisal
Copy link

its working thanks lot

@QODOHUB
Copy link

QODOHUB commented Jun 8, 2023

use JDK15 can fixed.
this fix is not work

@eurigo
Copy link

eurigo commented Jun 9, 2023

The default JDK version of Android Studio Flamingo is 17 image, which will cause the compilation to fail.

Solution:

  1. Install OpenJDK 11 or JDK 11
  2. Modify the default JDK version of Android Studio

    Settings --> Gradle --> Gradle JDK:(set your install JDK)

@payne1107
Copy link

use JDK15 can fixed.
this fix is not work
are you sure?

@nehal-gohil
Copy link

Use Gradle JDK 11 version from settings search gradle and select JDK version 11, Works for me

@payne1107
Copy link

payne1107 commented Jul 24, 2023 via email

@dineshrajamanikam
Copy link

Use JDK Version 11.0.19 actual version but use around 11 versions. it'll work.

@jdaccusys
Copy link

Hello!
I used this on my build.gradle(app)

    kotlin {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }

Plus this:

["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"](https://stackoverflow.com/questions/71257962/how-can-i-fix-this-error-with-butterknife-in-android-studio)

https://www.oracle.com/pk/java/technologies/javase/jdk11-archive-downloads.html
Download JDK 11 for your desired OS
Install it
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
Run The Project
Boom! it's works

Or migrate to viewBinding

@payne1107
Copy link

payne1107 commented Aug 28, 2023 via email

@Husnainfarooq
Copy link

go to Android Studio Preferences..., then Build, Execution, Deployment / Build Tools / Gradle, then set the Gradle JDK to be of some version 15

Yes i did the same, i changed it to jdk 11 and now my project is working fine

@hzyxym
Copy link

hzyxym commented Oct 17, 2023

tasks.withType(JavaCompile).configureEach {

how to use the kotlin file, thanks

@payne1107
Copy link

payne1107 commented Oct 17, 2023 via email

@softboy99
Copy link

same problem, Please don't deprecate this lib. Although there is view binding, this lib are still better than view binding.
eg.eliminating anonymous inner-classes for listeners by annotating methods with @OnClick and others.

@Patel-Parth12
Copy link

Patel-Parth12 commented Oct 20, 2023

Use JDK 15 it's works

build.gradle(Project):
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
}

build.gradle:
implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'

image

@bhushankalvani
Copy link

bhushankalvani commented Oct 21, 2023

The new Android APIs 33+ require Java version 17 to build the application. It's better to upgrade your code then to wait for the plugin to be updated. I removed the implementation for the code and instead made improvements to use Java/Kotlin latest setup to overcome challenges to move away from the plugin.

I know this may not be possible for everyone, so I am also working on a fix to upgrade this plugin itself.

Update: not picking up the upgrade immediately. On hold for now.

@yuwenjian
Copy link

转到 Android Studio Preferences...,然后 Build、Execution、Deployment / Build Tools / Gradle,然后将 Gradle JDK 设置为版本 15

这个可以解决

@Duna
Copy link

Duna commented Oct 30, 2023

Dropped the ButterKnife library because it is not supported for Gradle 8+ and Java 17+

@TWiStErRob
Copy link
Contributor

@JakeWharton doesn't this fall into the bucket of "critical bug fixes for integration with AGP" mentioned in the readme?
AGP 8 -requires-> Java 17 -causes> this issue.

@payne1107
Copy link

payne1107 commented Jan 2, 2024 via email

@JakeWharton
Copy link
Owner

If you are upgrading AGP then you should be upgrading away from Butter Knife. At this point it's been years so if you want to keep using an outdated library then I would suggest staying on equally outdated JDKs and AGPs.

@eaglean
Copy link

eaglean commented Jan 10, 2024

Which library can we use instead of this?

@payne1107
Copy link

Which library can we use instead of this?
use jdk 11 can solve

@TWiStErRob
Copy link
Contributor

@jay-asl19
Copy link

Even though I am using Gradle 8, just reducing the Java version to 11 from 17 resolved the issue. I was using command line to build my project locally. However I was getting this same error even though our pipeline on Gitlab was successfully building as the pipeline was using Java 11.

@jay-asl19
Copy link

Use JDK 15 it's works

build.gradle(Project): plugins { id 'com.android.application' version '7.1.2' apply false id 'com.android.library' version '7.1.2' apply false }

build.gradle: implementation 'com.jakewharton:butterknife:10.2.3' annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'

image

Worked for me with downgrading Java from 17 to 11.

@Pitel
Copy link
Contributor

Pitel commented Jan 30, 2024

I've modified my ancient project's gradle.properties file like this:

org.gradle.jvmargs=-Xmx2560m \
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED

And now it builds with latest Gradle (8.6 RC3), JDK 21 and latest Android Gradle Plugin (8.2.2)! 🎉

@payne1107
Copy link

payne1107 commented Jan 30, 2024 via email

@AlirezaIvaz
Copy link

Faced the same issue. With these configurations it's working for me:

  • JDK: 11
  • AGP: 7.1.2
  • Gradle: 7.2
  • Library: 10.2.3
  • Android Studio: Iguana 2023.2.1 Patch 2

@wangirving
Copy link

This is working for me :
JDK: 11
AGP: 7.1.2
Gradle: 7.2
Library: 10.2.3
Gradle JDK : corretto-11 Amazon Corretto version 11.0.21
Android Studio: Iguana 2023.2.1 Patch 2

@payne1107
Copy link

payne1107 commented Jun 27, 2024 via email

@shijia2118
Copy link

i solved this problem like below:
add the following code in your gradle.properties:

org.gradle.jvmargs=-Xmx1536m
--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

and it fixed.

@naylinndev
Copy link

naylinndev commented Jul 23, 2024

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

@payne1107
Copy link

payne1107 commented Jul 23, 2024 via email

@dukay159
Copy link

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

it's work, many thanks

@payne1107
Copy link

payne1107 commented Aug 14, 2024 via email

@snowf07
Copy link

snowf07 commented Sep 3, 2024

I have same problem in my guess gradle 8.0 need jdk17 but butterknife is not surport jdk 17

If you want support java 17 and above, please use app module build gradle file add code,

`
android {

tasks.withType(JavaCompile).configureEach{
    options.fork = true
    options.forkOptions.jvmArgs +=[
            '--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']
}`

}
more ,Refer to
https://stackoverflow.com/questions/71257962/how-can-i-fix-this-error-with-butterknife-in-android-studio

I hope you can help.

@asifali9145
Copy link

I have upgraded a toy project to AGP 8.0 through a few walkarounds below

# <app/build.gradle>

# https://stackoverflow.com/questions/65380359/lomboks-access-to-jdk-compilers-internal-packages-incompatible-with-java-16

# enable internal JDK API access at runtime
tasks.withType(JavaCompile).configureEach {
    options.fork = true
    options.forkOptions.jvmArgs += [
        # essential for butterknife
        '--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',

        # if you need Glide or LomBok
        # these may not be the exact list, but it works for me
        '--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',
    ]
}
# <gradle.properties>

# https://developer.android.com/build/releases/gradle-plugin#default-changes

# @BindView requires a constant resource ID
android.nonFinalResIds=false

Solution not worked for me , working on this

build.gradle (module)
classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.google.gms:google-services:4.4.2'

build.gradle (app)
implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'

@luerheng
Copy link

luerheng commented Oct 7, 2024

我对我的古老项目的gradle.properties文件进行了如下修改:

org.gradle.jvmargs=-Xmx2560m \
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED

现在它使用最新的 Gradle (8.6 RC3)、JDK 21 和最新的 Android Gradle 插件 (8.2.2) 进行构建!🎉

这个配置一下可以使用 我的, jdk17 gradle8.4 可以正常工作

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests