最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to Fix "Unable to load class 'com.android.build.api.dsl.ApplicationExtension'" in Flutter

programmeradmin4浏览0评论

I am facing the following issue in my Flutter project:

Unable to load class 'com.android.build.api.dsl.ApplicationExtension' com.android.build.api.dsl.ApplicationExtension

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

This project runs fine in debug mode on Chrome using flutter run -d chrome, but when I try to run flutter build apk --debug, I get this Gradle error.

How can I fix this issue?

I tried the following solutions:

Re-downloading dependencies – I clicked on the option to re-download dependencies and sync the project, expecting it to resolve any corrupt Gradle cache issues. However, the error persisted.

Stopping Gradle Daemons – I stopped all Gradle build processes and restarted the project, hoping it would fix any corrupt Gradle processes, but the issue remained.

Checking for Plugin Compatibility – I verified that all third-party plugins in my pubspec.yaml were compatible with the Flutter and Gradle versions I was using. Still, the error didn't go away.

Manually Killing Java Processes – I closed the IDE and manually killed all Java processes, expecting a fresh Gradle build on restart. Unfortunately, the error persisted.

I was expecting one of these steps to resolve the issue, but none of them worked. How can I fix this error?

I am facing the following issue in my Flutter project:

Unable to load class 'com.android.build.api.dsl.ApplicationExtension' com.android.build.api.dsl.ApplicationExtension

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

This project runs fine in debug mode on Chrome using flutter run -d chrome, but when I try to run flutter build apk --debug, I get this Gradle error.

How can I fix this issue?

I tried the following solutions:

Re-downloading dependencies – I clicked on the option to re-download dependencies and sync the project, expecting it to resolve any corrupt Gradle cache issues. However, the error persisted.

Stopping Gradle Daemons – I stopped all Gradle build processes and restarted the project, hoping it would fix any corrupt Gradle processes, but the issue remained.

Checking for Plugin Compatibility – I verified that all third-party plugins in my pubspec.yaml were compatible with the Flutter and Gradle versions I was using. Still, the error didn't go away.

Manually Killing Java Processes – I closed the IDE and manually killed all Java processes, expecting a fresh Gradle build on restart. Unfortunately, the error persisted.

I was expecting one of these steps to resolve the issue, but none of them worked. How can I fix this error?

Share Improve this question asked Mar 21 at 13:53 HASNAIN ANSARIHASNAIN ANSARI 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

For your explanation if it is the issue of Gradle then, these steps below will hard reset gradle. Please try it out.

In the android/gradle/wrapper/gradle-wrapper.properties, update the gradle version to:

distributionUrl=https\://services.gradle./distributions/gradle-8.9-all.zip

Run these commands on terminal to remove gradle from your project:

rm -rf android/.gradle

If you are using MacBook then gradle also gets downloaded in the following folder, please delete that too.

/Users/<user_name>/.gradle

This is what I would do if I came across the same issue.

In addtion,

  • Make sure you have JDK 11 or later installed.

  • JAVA_HOME should point to the correct Java installation directory.

If these do not work then, share both of your build.gradle files.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论