Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "$flutterSdkpath\packages\flutter_tools\gradle\app_plugin_loader.gradle" while running the app

I am facing an issue while running the app. My flutter details are:

Flutter Version: 1.12.13+hotfilx.9

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.17763.1098], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc2)
    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.6)
[√] VS Code (version 1.44.2)
[√] Connected device (1 available)
! Doctor found issues in 1 category.

While running the flutter run in visual studio it is showing this:

Launching lib\main.dart on CPH1859 in debug mode...

FAILURE: Build failed with an exception.

* Where:
Settings file 'project_name\android\settings.gradle' line: 15

* What went wrong:
A problem occurred evaluating settings 'android'.
> Could not read script '\flutter\packages\flutter_tools\gradle\app_plugin_loader.gradle' as it does not exist.

* 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
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Thanks in advance for helping me.

like image 625
Adarsh Srivastava Avatar asked Apr 26 '20 06:04

Adarsh Srivastava


People also ask

Why is my Gradle project not working in flutter?

Sign in to your account Exception: [!] Your app is using an unsupported Gradle project. To fix this problem, create a new project by running flutter create -t app <app-directory> and then move the dart code, assets and pubspec.yaml to the new project.

How do I fix [!] error in Gradle project?

Exception: [!] Your app is using an unsupported Gradle project. To fix this problem, create a new project by running flutter create -t app <app-directory> and then move the dart code, assets and pubspec.yaml to the new project.

Why is my flutter file not showing up in Android Studio?

Switching from master -> stable "downgrades" Flutter relative to that change, and the file is no longer present. You can work around this by regenerating your android/settings.gradle while on stable: $ rm android/settings.gradle $ flutter create .

What is the default error message in flutter?

By default, in debug mode this shows an error message in red, and in release mode this shows a gray background. When errors occur without a Flutter callback on the call stack, they are handled by the Zone where they occur. By default, a Zone only prints errors and does nothing else.


3 Answers

Flutter projects created on the master channel will generate an android/settings.gradle file that points to a file in the Flutter tool that's present in 1.18.0-dev.5.0 (currently available on all channels).

Switching from master -> stable "downgrades" Flutter relative to that change, and the file is no longer present.

You can work around this by regenerating your android/settings.gradle while on stable:

$ rm android/settings.gradle
$ flutter create .

See the GitHub issue for more details.

like image 91
Jenn Avatar answered Oct 26 '22 03:10

Jenn


Just replace the current setting.gradle file code with you wanna running version project setting.gradle. e.g: Other version project : android>setting.gradle

This code will be your current flutter version just replace your setting.gradle with old one or other project

Settings.gradle

include ':app' 

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
   pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
   def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
   include ":$name"
   project(":$name").projectDir = pluginDirectory
}
like image 7
Sahibzada Siraj Avatar answered Oct 26 '22 02:10

Sahibzada Siraj


Just downgrade the recent library/package you used and you'll be just fine

like image 3
Brian Kavishe Avatar answered Oct 26 '22 04:10

Brian Kavishe