VSCODE: Flutter failing to build for Android - flutter

flutter run
Launching lib/main.dart on AC2001 in debug mode...
Checking the license for package SDK Patch Applier v4 in /home/diva/Android/Sdk/licenses
Warning: License for package SDK Patch Applier v4 not accepted.
Checking the license for package Android Emulator in /home/diva/Android/Sdk/licenses
Warning: License for package Android Emulator not accepted.
Checking the license for package Android SDK Tools in /home/diva/Android/Sdk/licenses
Warning: License for package Android SDK Tools not accepted.
Checking the license for package Android SDK Build-Tools 29.0.2 in /home/diva/Android/Sdk/licenses
Warning: License for package Android SDK Build-Tools 29.0.2 not accepted.
Checking the license for package Android SDK Platform 30 in /home/diva/Android/Sdk/licenses
Warning: License for package Android SDK Platform 30 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.
patcher;v4 SDK Patch Applier v4
platforms;android-30 Android SDK Platform 30
emulator Android Emulator
tools Android SDK Tools
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: /home/diva/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 1s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 2,203ms
Exception: Gradle task assembleDebug failed with exit code 1
I am trying to run Flutter using VSCODE and haven't downloaded Android Studio. I have just started learning Flutter, so pretty new.
Android SDK build Tool == 29.0.3
and Flutter == 2.2.3
NEW: After running flutter doctor, It said I should run for android-licenses
Android toolchain - develop for Android devices
(Android SDK version 29.0.3)
• Android SDK at /home/diva/Android/Sdk
• Platform android-29, build-tools 29.0.3
• Java binary at:
/usr/lib/jvm/java-11-oracle/bin/java
• Java version Java(TM) SE Runtime Environment
18.9 (build 11.0.11+9-LTS-194)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to
accept the SDK licenses.
See
https://flutter.dev/docs/get-started/install/
linux#android-setup for more details.
[✓] Chrome - develop for the web
• Chrome at google-chrome
flutter doctor --android-licenses
Android sdkmanager tool not found
(/home/diva/Android/Sdk/tools/bin/sdkmanager).
Try re-installing or updating your Android SDK,
visit
https://flutter.dev/docs/get-started/install/linux#
android-setup for detailed instructions.

run this 'flutter doctor --android-licenses' then enter y for accepting each
licenses. the CMD will show you each license one by one which you have
to accept by entering y in CMD prompt. It solved my problem. I hope
this will also work for you

As the error output is suggesting. You need to accept license agreements
Android SDK packages as some licences have not been accepted.
to solve this
go to your terminal
flutter doctor --android-licenses
press (y) to
accept

Related

I'm getting the error 'cmdline-tools component is missing" and "Android license status unknown" , when i run the command flutter doctor

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
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.
--------xxxxxxxxxxxxxxxxxxxxxxxxx---------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx------------
I'm getting the above error on my windows 10 laptop. Can someone help me.
I was able to solve the issue using the following steps.
Updating the SDK in the Android Studio.
Updating the SDK tools in the Android Studio.
Downloading the Android SDK Command line Tools.
I followed this article : https://flutter-developer.medium.com/flutter-flutter-doctor-results-with-cmdline-tools-component-is-missing-f6371a9c6e97

Flutter App stuck at "Running Gradle task 'assembleDebug'

My flutter app when run from VScode is always stuck at running-gradle-task-assembledebug
When I run flutter run -v in command prompt, it works but not from VSCode. This issue seems to have come since last week.
Tried ./gradlew clean and ./gradlew clean build, this works sometimes and buils from vscode
Deleted and created a new emulator device and also tried many suggestions online
Output from flutter doctor -v
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19044.1415], locale en-US)
• Flutter version 2.8.1 at E:\Flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (4 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at E:\sdk\Android
• Platform android-31, build-tools 30.0.2
• ANDROID_SDK_ROOT = E:\sdk\Android
• Java binary at: F:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 2020.3)
• Android Studio at F:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] Connected device (3 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.71
• Edge (web) • edge • web-javascript • Microsoft Edge 96.0.1054.62
• No issues found!
created a brand new flutter project and did gradlew clean and got below messages for gradlew clean --warning-mode all
> Configure project :app
Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you should use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:extendsFrom(org.gradle.api.artifacts.Configuration[]) for more details.
at build_59yj46qtreisbbowxqfuhj29p$_run_closure3.doCall(D:\MobileDevelopment\GitRepo\jigsaw\android\build.gradle:26)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
at FlutterPlugin$_addFlutterTasks_closure20$_closure44.doCall(E:\Flutter\packages\flutter_tools\gradle\flutter.gradle:833)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
at FlutterPlugin$_addFlutterTasks_closure20$_closure44.doCall(E:\Flutter\packages\flutter_tools\gradle\flutter.gradle:834)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
BUILD SUCCESSFUL in 2s
2 actionable tasks: 2 up-to-date
Running gradlew build gives
> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libflutter.so.
> Task :app:stripProfileDebugSymbols
Unable to strip the following libraries, packaging them as they are: libapp.so, libflutter.so, libvmservice_snapshot.so
> Task :app:lint FAILED
Ran lint on variant debug: 3 issues found
Ran lint on variant release: 3 issues found
Ran lint on variant profile: 3 issues found
Wrote HTML report to file:///D:/MobileDevelopment/GitRepo/jigsaw/build/app/reports/lint-results.html
Wrote XML report to file:///D:/MobileDevelopment/GitRepo/jigsaw/build/app/reports/lint-results.xml
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
Errors found:
D:\MobileDevelopment\GitRepo\jigsaw\android\app\src\main\AndroidManifest.xml:5: Error: Class referenced in the manifest, com.example.jigsaw.${applicationName}, was not found in the project or the libraries [MissingClass]
android:name="${applicationName}"
~~~~~~~~~~~~~~~~~~
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 26s
94 actionable tasks: 90 executed, 4 up-to-date
Redownloaded flutter 2.8 sdk from google official docs which also has dart in it and retried.
It's due to your gradle is downloading it's version but sometimes it's speed download too low and won't be downloaded, you can fix it :
first check your gradle version in root of your project :
<project name> > android > gradle > wrapper > gradle-wrapper.properties
and check distributionUrl , you will see which gradle version is using in project and is downloading , so you should download that version in this link https://services.gradle.org/distributions/
after you download, copy and go to this directory :
C:\Users\<user name>\.gradle\wrapper\dists\gradle <your version>\<a file with weird name>\
paste and unzip your downloaded file here.
it works for me every time I hope for you too.
let me know if there is any question.
I did solve the problem by first executing
flutter clean
and then, in order to recompile the project daet files
flutter pub upgrade

Unable to build AAR, Task 'assembleAarDebug' not found

flutter build aar fail
error info :
Task 'assembleAarDebug' not found in root project 'android_generated'.
sudo flutter build aar fixed this problem,but wo want't do it,
fluter doctor info
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable/v1.17.5.taobao, v1.17.0-4.0.pre.32, on Mac OS X 10.15.6 19G2021, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart
side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.51.1)
[!] Connected device
! No devices available
some one can help me
I fixed this problem
org.gradle.configureondemand=false, This configuration is useful to me, this is the truth。
In the initialization script(aar_init_script.gradle),the task assembleAarDebug is be Added by the method projectsEvaluated。
if you set 'org.gradle.configureondemand=true', The execution order of the script has been modified, The task assembleAarDebug has not been added yet, gradle will execute it。
This is the cause of this error(Unable to build AAR, Task 'assembleAarDebug' not found).
Note that the priority of gradle.properties in the gradle home directory(/Users/username/.gradle/) is higher than that in the project。

How to Install Android SDK commandline tool for Flutter upgrade error?

How to install Android SDK commandline tool on a Ubuntu remote server which doesn't have Display/GUI.
When I run, 'flutter upgrade' it gives me the below and I wanted to know if I can use Android SDK commandline tool for resolving the issue.
$flutter upgrade
Upgrading Flutter from /home/yvelumani/flutterDev/sdk/flutter...
Building flutter tool...`
Upgrading engine...
Downloading Android Maven dependencies...
Failed to download the Android dependencies
Downloading Android Maven dependencies... 127.7s (!)
Flutter 1.22.0-10.0.pre.133 • channel master • https://github.com/flutter/flutter.git
Framework • revision 577de1c44e (46 minutes ago) • 2020-09-10 15:55:03 -0700
Engine • revision fee6f9e533
Tools • Dart 2.10.0 (build 2.10.0-110.0.dev)
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.22.0-10.0.pre.133, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
✗ Android SDK file not found: adb.
[!] Android Studio (not installed)
[✓] Proxy Configuration
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
I have downloaded android SDK commandline tool from https://developer.android.com/studio#command-tools. But I am not sure how to install this tool and what path to be chosen as ANDROID_HOME?
NOTE: I am not going/able to use Android Studio for my app development.
Thanks for the help in advance.
Android Studio >> Tools >> SDK Manager >> SDK Tools >> Android SDK Command Line Tools

Unable to run flutter app in android studio

I created a new flutter project and when run it, it gives that error
Target kernel_snapshot failed: Exception: The value of -DDartDefines is not formatted correctly.
The value must be a JSON-encoded list of strings but was:
[flutter.inspector.structuredErrors=true]
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\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
Exception: Gradle task assembleDebug failed with exit code 1
I have tried flutter clean, and same error
flutter doctor log :
D:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel master, v1.16.4-pre.69, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
• Flutter version 1.16.4-pre.69 at D:\flutter
• Framework revision 19e7db585d (4 months ago), 2020-04-01 11:16:01 -0700
• Engine revision c9506cb8e9
• Dart version 2.8.0 (build 2.8.0-dev.18.0 eea9717938)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\user\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[!] VS Code (version 1.47.2)
• VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
Process finished with exit code 0
According to what flutter doctor is giving you the problem might be related to Android Sdk not installed or not configured really well:
Flutter provides a command to update the Android SDK path: Use
flutter config --android-sdk <path-to-your-android-sdk-path>
You can install it directly from Android Studio:
To open the SDK Manager from Android Studio, click Tools > SDK Manager or click SDK Manager in the toolbar. You might have to uncheck "hide obsolete packages" and install the packages that were considered obsoletes.
Or you can install it from this link and configure it like I said before:
https://www.google.com/url?sa=t&source=web&rct=j&url=https://android-sdk.fr.uptodown.com/windows&ved=2ahUKEwi-itWCkuzqAhXTZTUKHa29CRMQFjACegQIAhAB&usg=AOvVaw1QSSVVMrZzFltXvboDbTeQ