0

I have a flutter app I've been working on. It was working fine till yesterday. Then I started getting this error when I try to run it on Android:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Exception in thread "main" java.lang.RuntimeException: Gradle distribution 'https://services.gradle.org/distributions/gradle-7.5-all.zip' does not contain any directories. Expected to find exactly 1 directory.
    at org.gradle.wrapper.Install.getAndVerifyDistributionRoot(Install.java:115)
    at org.gradle.wrapper.Install.access$000(Install.java:27)
    at org.gradle.wrapper.Install$1.call(Install.java:76)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Exception: Gradle task assembleDebug failed with exit code 1

It started working fine today, then I got this error again for no apparent reason. I was testing the app, I hot-restarted, and I got this error.

I have tried deleting the whole Android project and regenerating it with flutter create my_project_name, but when the android project got recreated, I got the same error again.

I tried to run it on my physical phone and I got the same error.

Here is the result of flutter doctor:

[√] Flutter (Channel stable, 3.7.10, on Microsoft Windows [Version 10.0.18363.628], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.3)
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.77.3)
[√] Connected device (3 available)
[√] HTTP Host Availability

Please, what could be the problem?

Update: It's like that for all my projects. Nothing is running. All projects are giving me this same error.

Olumide
  • 98
  • 7
  • Something got messed up with your gradle config. Check `gradle/wrapper/gradle-wrapper.properties`. You can also open the android project separately with AS/VS and then sync gradle. – Rohan Kandwal May 11 '23 at 14:23
  • How do I sync gradle? – Olumide May 11 '23 at 15:24
  • This is the ```gradle/wrapper/gradle-wrapper.properties```: ```distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip``` – Olumide May 11 '23 at 15:31

1 Answers1

1

Solved. Thank you, @Rohan Kandwal. How to solve it:

Right-chick the android folder in the Android studio project, then you click "Flutter", then click "Open Android module in Android Studio". This will open the android project. Then I tried to run the project from there. It gave an error but gave the option to "Delete and sync" after the error message. I clicked that and then I tried to run it again. This time it gave this error. The error was solved by running Android Studio as Administrator.

Olumide
  • 98
  • 7