Gradle Version in VSCode running Flutter app - flutter

I've install the VSCode, Android Studio, and Flutter in my windows. when I try to launch the android emulator (Pixel 4 API TiramisuPrivacySandbox) and Run the app ( default test app generated in VSCode - click counter) I get an error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:7.1.2.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom
https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom
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 31s
Exception: Gradle task assembleDebug failed with exit code 1
** in gradle-wrapper.properties file, the gradle version is 7.4
> distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
** in build.gradle file, the gradle version is 7.1.2
> dependencies {
> classpath 'com.android.tools.build:gradle:7.1.2'
> classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
> }`
** in web or windows devices, it runs without error.

Internet Issue ,Check your Internet Connection
if your internet is ok still having this issue then you need to change the internet connection (can use VPN) and try again hope it will work

Related

Flutter app run issue - FAILURE: Build failed with an exception

FAILURE: Build failed with an exception.
* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
The following dependencies do not satisfy the required version:
project ':platform_device_id' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50
* 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
Exception: Gradle task assembleDebug failed with exit code 1
In .yaml file platform_device_id: ^1.0.1
',I need to fix app run issues.
It's an error due to the latest version of Gradle used in the project.platform_device_id Package contains a lower Gradle and Kotlin version that is not supported to build with the latest Gradle version.
There's also a GitHub issue ongoing, you can check it out with this link
The solution is to use this plugin called device_info_plus instead. It is presented by the Flutter community itself so it works seamlessly as you expected. Also, it works will all platforms.

NDK not configured. Download it with SDK manager when compile flutter app

Today when I compile the flutter(2.5.1) app, show error like this:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':system_clock'.
> NDK not configured. Download it with SDK manager. Preferred NDK version is '21.1.6352462'.
* 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
Exception: Gradle task assembleDebug failed with exit code 1
I have already checked the NDK configuration and make sure the version is installed:
why the project prefer another version of NDK version? what should I do to configure the right version of NDK?
Just check '21.1.6352462' in NDK and press ok.
It'll do the rest.
Or check this issue
https://github.com/flutter/flutter/issues/53657

There is a error in android studio but same code working on flutlab.io

i tried to run a basic code in android studio. but it showing error. but the same code successfully compiled on flutlab.io
here is the error message.
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\HP\AndroidStudioProjects\helloapp\android\settings.gradle' (C:\Users\HP\.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
> 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 2s
Exception: Gradle task assembleDebug failed with exit code 1
i'm new to android studio. so please tell what's the wrong here.
Try to use JAVA SDK 15.
First remove your old JDK, and download & install Java JDK 15 from here.
Then, in Android Studio, change the path to the Java JDK so that it matches the latest install. Finally, restart Android Studio to apply the changes.

Could not resolve all task dependencies for configuration ':google_sign_in:debugCompileClasspath'

App was working completely fine but suddenly it is invoking the following issue.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':google_sign_in:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':google_sign_in:debugCompileClasspath'.
> Could not resolve project :google_sign_in_web.
Required by:
project :google_sign_in
> Unable to find a matching configuration of project :google_sign_in_web:
- None of the consumable configurations have attributes.
* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
I have imported the latest google_sign_in package in pubspec.yaml but still facing the same build failed error. Any help please!
Solved it by running following command in flutter terminal:
flutter pub cache repair
All of the packages were downloaded and re-installed again.

Could not resolve all artifacts for configuration ':app:debugCompileClasspath'

After the flutter 1.17 update, I tried to run my app, but it shows this error. flutter doctor command works fine. I don't understand what is happening
Launching lib\main.dart on Redmi Note 7 Pro in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
> Could not download arm64_v8a_debug.jar (io.flutter:arm64_v8a_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5)
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-540786dd51f112885a89792d678296b95e6622e5/arm64_v8a_debug-1.0.0-540786dd51f112885a89792d678296b95e6622e5.jar'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-540786dd51f112885a89792d678296b95e6622e5/arm64_v8a_debug-1.0.0-540786dd51f112885a89792d678296b95e6622e5.jar'.
> Remote host closed connection during handshake
* 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 12s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I met with a similar problem of unavailability of kotlin sdk resources. Couldn't find a quick solution, but the problem was most likely on the server side with resources. Because the next morning, the whole assembly was successful.
Perhaps you should just wait, if before that everything was going fine and suddenly stopped.
After reading the entire branch, I still did not find a solution for my case, but it may be useful to someone.
https://github.com/flutter/flutter/issues/23553
I had a similar issue and it was resolved when I changed the following settings in my build.gradle file:
ext.kotlin_version = '1.3.61' //from 1.3.50
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3' //from 3.5.0
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}