Gradle task assembleDebug failed with exit code -1 - android

I am repeatedly getting this error again and again despite trying everything I could find online.
So far I have done these steps to solve this problem:
Removed android stuido, intelliJ and flutter and installed all of it again.
Reinstalled all SDK packages several times, i have attached image of all SDK packages for refernece.Please have a look.
Accepted all licenses.
C:\Users\Asus>flutter doctor --android-licenses
All SDK package licenses accepted.======] 100% Computing updates...
C:\Users\Asus>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.1, on Microsoft Windows [Version 10.0.18363.836], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc4)
[√] Android Studio (version 3.6)
[√] Connected device (1 available)
• No issues found!
Tried using earlier version of flutter and tried again after upgrading it.
After doing all this I am still getting this error for all projects. Even the basic project which is pre-written when creating a new flutter project.
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
Exception: Gradle task assembleDebug failed with exit code -1

Related

Flutter: Unable to generate build files, A Required package was not found

Tried to build a basic linux app following the official Flutter google-colab tutorial and got stuck with this error
Launching lib/main.dart on Linux in debug mode...
lib/main.dart:1
CMake Error at /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:825 (_pkg_check_modules_internal)
flutter/CMakeLists.txt:25 (pkg_check_modules)
Exception: Unable to generate build files`
OS: Linux Mint
IDE: VScode
Tried to find the missing modules so i could install. Was unsuccessful. Need more expertise in that part. Please help :)
edit: installed libgtk-3-dev since it was a requirement as stated from flutter doctor
which said
root#lax:/home/lax/Flutter/vibeo# flutter doctor
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
📎
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.10, on Linux Mint 21.1 5.15.0-57-generic, locale en_IN)
Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Linux toolchain - develop for Linux desktop
✗ GTK 3.0 development libraries are required for Linux development.
They are likely available from your distribution (e.g.: apt install libgtk-3-dev)
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.74.2)
[✓] Connected device (1 available)
[✓] HTTP Host Availability
! Doctor found issues in 2 categories.
and still the build fails
Launching lib/main.dart on Linux in debug mode...
lib/main.dart:1
ERROR: Flutter failed to create a directory at "/home/lax/Flutter/vibeo/.dart_tool/flutter_build/a631d39312be8637492918f28fa31d2e".
Exception: Build process failed
Exited (sigterm)

"Gradle task assembleDebug failed with exit code 1" because "Could not find or load main class org.gradle.wrapper.GradleWrapperMain"

I'm new to flutter and I want to make the default flutter app to show up on my Android emulator. The emulator starts up fine but the process fails at "gradle task assembleDebug". I reinstalled everything ranging from Android Studio to flutter and dart and also deleting the AVD from Android Studio then creating it again but nothing seems to work. I tried a few potential fixes from youtube and google searches involving running a "gradle wrapper" command at the root directory but that doesn't work too as the root directories of all flutter apps lacks the "build.gradle" file. Flutter doctor does not show any problems.
"flutter doctor" command output:
PS C:\Users\Mahmud Alam\Desktop\Programming Stuff\Flutter&Dart\newproj\firstapp> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.22000.675], locale en-US)
Checking Android licenses is taking an unexpectedly long time...[√] 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 2019 16.11.10)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.67.2)
[√] Connected device (4 available)
[√] HTTP Host Availability
• No issues found!
Error output in command line:
PS C:\Users\Mahmud Alam\Desktop\Programming Stuff\Flutter&Dart\newproj\firstapp> flutter run
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 in debug mode...
'Dart\newproj\firstapp\android\' is not recognized as an internal or external command,
operable program or batch file.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
Running Gradle task 'assembleDebug'... 19.6s
Exception: Gradle task assembleDebug failed with exit code 1
I get the feeling that something is missing from somewhere but I cant figure out where and how to restore the files that are missing. Also, I'm running an emulation of Pixel 2 API 30 (android x86). But that alone should not cause any problems. How do I fix this?
Edits: [Folder Structure Screenshots]
I think this is your "&" of Flutter&Dart which cause the problem.
Try running flutter clean in your terminal and then rebuilding the app, that's worked for me in the past.
Delete the flutter cache (/bin/cache);
Delete gradlew and gradlew.bat in android folder (and in some cases android/gradle/wrapper/gradle-wrapper.jar too);
Run flutter run again.
This steps worked for me.

Problem with running flutter with androis configurations on windows machine

I've been trying to run my Flutter app in VScode, but the following message appears:
Microsoft Windows [versão 10.0.19042.928]
(c) Microsoft Corporation. Todos os direitos reservados.
C:\projects\tests\fluttertest>flutter run
Launching lib\main.dart on Google Nexus 7 in debug mode...
Checking the license for package Android SDK Build-Tools 29.0.2 in C:\Users\sophi\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Build-Tools 29.0.2 not accepted.
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;29.0.2 Android SDK Build-Tools 29.0.2
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:\Users\sophi\AppData\Local\Android\sdk
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 16s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 17,2s
Exception: Gradle task assembleDebug failed with exit code 1
Also, when I run the flutter doctor in prompt it returns the following message
C:\src\flutter>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.5, on Microsoft Windows [versão 10.0.19042.928], locale pt-BR)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.55.2)
[√] Connected device (3 available)
! Doctor found issues in 1 category.
C:\src\flutter>flutter doctor --android-license
Could not find an option named "android-license".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
C:\src\flutter>flutter doctor --android-licenses
Warning: File C:\Users\sophi\.android\repositories.cfg could not be loaded.
7 of 7 SDK package licenses not accepted. 100% Computing updates...
Review licenses that have not been accepted (y/N)?
I've looked for my repositories.cfg file and it doesn't exist.
Go to SDK Manager and download android 10(if using android studio)
Make sure to download JDK Version 1.8
Run flutter doctor --android-licenses in the terminal
Run : Flutter doctor --andriod-licenses...
Then rund your code back

Launching lib\main.dart on Redmi Note 4 in debug mode... Running Gradle task 'assembleDebug'... taking too much time

I am new in flutter recently installed flutter in an android studio and run the app but unfortunately, it takes too much time, then I wait 30 to 60 minutes but it not running it stack at
Launching lib\main.dart on Redmi Note 4 in debug mode...
Running Gradle task 'assembleDebug'...
my flutter doctor cmd output is
PS C:\Windows\system32> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.4, on Microsoft Windows [Version 10.0.18362.900], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] VS Code (version 1.46.1)
[√] Connected device (1 available)
• No issues found!
'Running Gradle task 'assembleDebug' usually will take a long time. But once you run it, you can use hot reload for reloading it in about less than one second. But if it is taking too much time, may be you are having a slower PC, or you are stuck inside a loop, or your phone has been disconnected while gradle was running. Check if you have your cable connected to phone is loose. As flutter is still under development there are lots of things to be updated. Unfortunately there is no other option to cancel the gradle run, so you will have to restart your android studio.
Hope it helps.

I face this error while running the first app in flutter , how to solve it?

This is my log message, Android studio 3.1.2 , I get the same error in intellij and also in visual studio code :
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Finished with error: Exit code 1 from: X:\Android(exp+1)\flutter\flutter_appnew\android\gradlew.bat -v:
'X:\Android' is not recognized as an internal or external command,
operable program or batch file.
This is my flutter doctor result :
C:\Users\kunda>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.3.2, on Microsoft Windows [Version 10.0.16299.431], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Ultimate Edition (version 2018.1)
[√] VS Code, 64-bit edition (version 1.22.2)
[√] Connected devices (1 available)
• No issues found!
You should move your flutter project to a directory without parenthesis, so e.g. X:\Android\flutter\flutter_appnew

Categories

Resources