英文:
'compileDebugJavaWithJavac' error with Android Studio Flamingo
问题
When I updated Android Studio to Flamingo version, Gradle suggested the upgrade and I upgraded with AGP from 7.4 to 8.0. I was never able to debug after this upgrade, and as a result of my research, I could not come to a conclusion. If there is any information I have given missing for the problem, if you specify, I can make additions. I'm sharing my gradle module app codes because I think the problem stems from here.
My build.gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 33
defaultConfig {
applicationId "com.example.packagename"
multiDexEnabled true
minSdkVersion 22
targetSdkVersion 33
versionCode 15
versionName "1.4"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
namespace 'com.example.packagename'
}
Error:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> superclass access check failed: class butterknife.compiler.ButterKnifeProcessor$RScanner (in unnamed module @0x1db9193f) 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 @0x1db9193f
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
.
.
.
I tried almost all the suggestions mentioned in StackOverFlow for solution but couldn't reach a solution.
<details>
<summary>英文:</summary>
When I updated Android Studio to Flamingo version, Gradle suggested the upgrade and I upgraded with AGP from 7.4 to 8.0. I was never able to debug after this upgrade, and as a result of my research, I could not come to a conclusion. If there is any information I have given missing for the problem, if you specify, I can make additions. I'm sharing my gradle module app codes because I think the problem stems from here.
My build.gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 33
defaultConfig {
applicationId "com.example.packagename"
multiDexEnabled true
minSdkVersion 22
targetSdkVersion 33
versionCode 15
versionName "1.4"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
namespace 'com.example.packagename'
}
Error:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> superclass access check failed: class butterknife.compiler.ButterKnifeProcessor$RScanner (in unnamed module @0x1db9193f) 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 @0x1db9193f
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
.
.
.
I tried almost all the suggestions mentioned in StackOverFlow for solution but couldn't reach a solution.
</details>
# 答案1
**得分**: 4
现在唯一能确保项目可构建的方法是确保使用Java 11。
1. 在Android Studio中转到`设置 -> 构建,执行,部署 -> 构建工具 -> Gradle`
2. `Gradle JDK` - 确保选择了Java 11
3. 如果这没有帮助,不要更改设置,而是尝试使用选项“使缓存无效...”,然后重新启动Android Studio,看看是否有帮助。
另外,我建议将AGP降级回7.4。我知道这不会带来所有的功能和修复,但正如你所说,关于我们可以做什么,现在有很少的信息。
另一方面,Butterknife的作者声称他将处理与AGP集成的“关键错误修复”:
[![进入图片描述][2]][2]
还要确保你已经配置了`build.gradle`文件来使用Java 11:
compileOptions {
sourceCompatibility = "11"
targetCompatibility = "11"
}
<details>
<summary>英文:</summary>
For now the only way how to get your project buildable is to make sure to use Java 11.
1. In Android Studio go to `Settings -> Build, Execution, Deployment -> Build Tools -> Gradle`
2. `Gradle JDK` - make sure you have selected Java 11
3. In case it did not help, do not change the setting, rather try "Invalidate Caches..." with option to restart Android Studio and see if that helps.
Also I would suggest to downgrade AGP back to 7.4. I know that this does not bring all the features and fixes on board, but as you said, there are few info out there about what we can do, now.
On the other hand, author of Butterknife [claims][1] that he will manage "critical bug fixes for integration with AGP":
[![enter image description here][2]][2]
Also make sure that you have configure your `build.gradle` file to use Java 11:
compileOptions {
sourceCompatibility = "11"
targetCompatibility = "11"
}
[1]: https://github.com/JakeWharton/butterknife
[2]: https://i.stack.imgur.com/CU1M3.png
</details>
# 答案2
**得分**: 1
I solved the problem by reverting to the old version as follows.
First of all, I downloaded and installed the Electric Eel version. (Official archive site to download old versions: [**CLICK**][1])
I then changed the content of **gradle-wrapper.properties** to:
distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Then I set the **Gradle JDK** with the steps "**File > Build, Execution, Deploymend > Gradle**" as follows: **jbr-11** *(Jetbrains Runtime version 11.0.5...)*
I then followed these steps: "**File > Project Structure**"
And
Android Gradle Plugin Version: **7.4.2**
Gradle Version: **8.0.1**
Right now at least I'm able to compile and run my project.
Thanks to everyone who tried to help.
[1]: https://developer.android.com/studio/archive
<details>
<summary>英文:</summary>
I solved the problem by reverting to the old version as follows.
First of all, I downloaded and installed the Electric Eel version. (Official archive site to download old versions: [**CLICK**][1])
I then changed the content of **gradle-wrapper.properties** to:
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Then I set the **Gradle JDK** with the steps "**File > Build, Execution, Deploymend > Gradle**" as follows: **jbr-11** *(Jetbrains Runtime version 11.0.5...)*
I then followed these steps: "**File > Project Structure**"
And
Android Gradle Plugin Version: **7.4.2**
Gradle Version: **8.0.1**
Right now at least I'm able to compile and run my project.
Thanks to everyone who tried to help.
[1]: https://developer.android.com/studio/archive
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论