FLUTTER FIRST RUN: Build failed with an exception - flutter

I'm trying to perform my first run of a test app on flutter via Genymotion, but I get nothing except this message in console:
Launching lib\main.dart on Motorola Moto X in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.5.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 26s
Finished with error: Gradle task assembleDebug failed with exit code 1
Also (it may be helpful, I think), under the build menu, I don't find some practical sub-menus; such as build, clean, or ...
What could be the problem?
any help is really appreciated!
Since #TaufikNurRahmanda needed the response of flutter doctor and flutter clean commands as more details, I am adding them as an edit;
flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [Version 10.0.10586], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed
instructions.
[√] Android Studio (version 3.4)
[√] IntelliJ IDEA Community Edition (version 2019.3)
[√] Connected device (1 available)
! Doctor found issues in 1 category.
flutter clean:
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Do not run this command from the root of your git clone of Flutter.
Also the response of flutter doctor --android-licenses may be useful (although I have Android SDK Build-tools 29.0.3 installed):
A newer version of the Android SDK is required. To update, run: C:\Users\[user]\AppData\Local\Android\android-sdk\tools\bin\sdkmanager --update
And when I run the suggested command above (sdkmanager --update), I get this:
Error: Could not find or load main class '-Dcom.android.sdklib.toolsdir=C:\Users\[user]\AppData\Local\Android\android-sdk\tools\bin\\..-XX:+IgnoreUnrecognizedVMOptions

Seems you do not accepted some android licenses. Just run:
flutter doctor --android-licenses
And accept y all licences.

Related

flutter new created project don't run

just created new flutter project with the command flutter create test.
When start it failed with this error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'D:\sandbox\mobile-app\sheba\testapp\android\settings.gradle' (C:\Users\grebe\.gradle\caches\7.4\scripts\ea4ydi90mwjg9g63m7r6nimmx).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Device: Emulated Android 12
Flutter doctor output is:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [version 10.0.22621.1105], locale fr-FR)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.15)
[!] Android Studio (version 2022.1)
X Unable to find bundled Java version.
[√] VS Code (version 1.74.3)
[√] Connected device (4 available)
[√] HTTP Host Availability
! Doctor found issues in 1 category.
Thanks for help :)
run " --flutter doctor " and share the result
is it your first project with flutter on your device ?
Also mention what is your device and it's OS version.
Problem: [!] Android Studio (version 2022.1) X Unable to find bundled Java version.
answer : Go to "C:\Program Files\Android\Android Studio" and then copy the content of jbr and paste the content into jre folder run doctor again
just change your gradle version to 7.6 .
follow the steps 1android>gradle>gradle-property
check this line distributionUrl=https://services.gradle.org/distributions/gradle-7.6-all.zip)
this 7.6 should not be 7.4 or less

Flutter Build error is resulting to a error , Could not load compiled classes for build

The whole code was working well last week, and now I try to open the same project and run the flutter build apk
It shows below error
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':location'.
> Could not load compiled classes for build file 'D:\\flutter.pub-cache\\hosted\\pub.dartlang.org\\location-4.4.0\\android\\build.gradle' from cache.
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for the project ':location' of type org.gradle.api.Project.
> Could not get unknown property 'android' for the project ':location' of type org.gradle.api.Project.
* Try:
ore log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
Gradle task assembly release failed with exit code 1
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
US)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.6)
[√] Android Studio (version 2021.3)
[√] Connected device (3 available)
[√] HTTP Host Availability
• No issues found!
I tried cleaning the pub cache folder and also running pub get commands, but the build is not succeeding

Error while building Flutter APK for android-arm only

I got into this problem since last month. I can build APK for android-arm64, android-x86, all of them combined but not specifically for android-arm.
I use this command to build:-
flutter build apk --target-platform android-arm --analyze-size
After running this I'm getting the error:-
Building with sound null safety
Dart snapshot generator failed with exit code -2147483645
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4m 54s
Running Gradle task 'assembleRelease'... 295.9s
Gradle task assembleRelease failed with exit code 1
Output for flutter doctor is:-
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.22000.527], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.0.6)
[√] Android Studio (version 2021.1)
[√] VS Code (version 1.65.0)
[√] Connected device (3 available)
[√] HTTP Host Availability
• No issues found!
I tried changing gradle versions to 6.7-all, 7.3.1-bin and 7.2-bin
I tried removing flutter folder and reinstalling it all
The problem was with flutter itself after the new update.
It is covered in this issue

this is the error I am getting every time I try to run the code that flutter provides in main.dart

FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\devsh\Desktop\programs_\StudioProjects\untitled\android\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not open proj generic class cache for build file 'C:\Users\devsh\Desktop\programs_\StudioProjects\untitled\android\app\build.gradle' (C:\Users\devsh\.gradle\caches\6.7\scripts\67wpoy60578g543vmv9v5k2r9).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Exception: Gradle task assembleDebug failed with exit code 1
and this is not it. I have installed android studio still my flutter doctor shows me that I haven't installed it yet and also there is some license issue I don't know how to solve
this is my result of flutter doctor
C:\Users\devsh>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19042.985], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[√] VS Code (version 1.55.2)
[√] Connected device (2 available)
! Doctor found issues in 3 categories.
For the Android license issue, what happens when you run flutter doctor --android-licenses on the command line? Hopefully, it'll run you through the steps to accept the licenses.
For the unsupported class issue, does running a Gradle clean solve the problem? To do this, you should be able to navigate to the projects android directory on the command line and run gradlew clean.

Flutter: Debug build successful but release gives error

After updating the flutter to 1.12.13+hotfix.8, Flutter gives strange errors on release build, but works perfectly fine in debug build
Error :
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'intent'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or
by setting the sdk.dir path in your project's local properties file at
'/Users/niyantras/tools/flutter/.pub-cache/hosted/pub.dartlang.org/intent-
1.1.0/android/local.properties'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to
get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Flutter doctor :
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.42.0)
[✓] Connected device (1 available)
• No issues found!
Can someone help me in figuring out, thanks for the help.
flutter clean
flutter pub cache repair
let me know if the issue persists
check here, it's closed issues of flutter
Check for compilesdkversion everywhere in the folder and match it with one in android/app/build.gradle