重装Android Studio后Flutter项目Gradle运行报错(Exit code 1)
Gradle Build Error:
java.net.BindException: Address already in use When Debugging Flutter on Redmi 4 Problem Description
After reinstalling Android Studio, I tried launching my Flutter app (lib\main.dart) in debug mode on my Redmi 4, but ran into this Gradle build failure:
Launching lib\main.dart on Redmi 4 in debug mode... Initializing gradle... [{"event":"app.progress","params":{"appId":"4a13515b-84ae-422f-af52- 5d0ab7112e30","id":"1","progressId":null,"message":"Resolving dependencies..."}}]Resolving dependencies... * Error running Gradle: Exit code 1 from: C:\Users\RAJESH\AndroidStudioProjects\flutte\android\gradlew.bat app:properties: FAILURE: Build failed with an exception. * What went wrong: java.net.BindException: Address already in use: Cannot bind * Try: Run with --stacktrace option to get the stack trace. Run with --info or -- debug option to get more log output. * Get more help at https://help.gradle.org Finished with error: Please review your Gradle project setup in the android/ folder.
Fixed It! Here's What Worked
After digging into the issue, I identified two root causes:
- Slow/unstable network: Gradle couldn't resolve dependencies properly due to poor network speed
- Stale build files: Old cached files in the project's
builddirectory were causing connection conflicts
To resolve the problem, I took these steps:
- Deleted the entire
buildfolder inside theandroiddirectory of my Flutter project - Switched to a stable network connection to ensure dependency resolution completes smoothly
- Restarted Android Studio and re-launched the app in debug mode
That fixed the bind exception, and the app ran successfully on my Redmi 4.
内容的提问来源于stack exchange,提问作者Rajesh
相关产品推荐
相关产品推荐

