运行应用程序时出现错误“$flutterSdkpath\packages\flutter_tools\gradle\app_plugin_loader.gradle”
Posted
技术标签:
【中文标题】运行应用程序时出现错误“$flutterSdkpath\\packages\\flutter_tools\\gradle\\app_plugin_loader.gradle”【英文标题】:Error "$flutterSdkpath\packages\flutter_tools\gradle\app_plugin_loader.gradle" while running the app运行应用程序时出现错误“$flutterSdkpath\packages\flutter_tools\gradle\app_plugin_loader.gradle” 【发布时间】:2020-08-09 16:57:06 【问题描述】:我在运行应用程序时遇到问题。 我的颤振细节是:
Flutter 版本: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.
在 Visual Studio 中运行颤振运行时,它显示如下:
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)
提前感谢您帮助我。
【问题讨论】:
即使我也面临同样的问题 【参考方案1】:在主通道上创建的 Flutter 项目将生成一个 android/settings.gradle
文件,该文件指向 Flutter 工具中存在于 1.18.0-dev.5.0 (currently available on all channels) 中的文件。
从 master 切换 -> 相对于该更改,稳定“降级”Flutter,并且该文件不再存在。
您可以通过在稳定时重新生成 android/settings.gradle
来解决此问题:
$ rm android/settings.gradle
$ flutter create .
有关详细信息,请参阅GitHub issue。
【讨论】:
感谢您的回答,它有帮助 错误地运行了这条评论,我丢失了所有没有备份的代码。我可以通过命令行返回之前的代码吗 不,@AbirAhsan,您无法恢复代码的先前状态:如果它没有通过某些版本控制保存,则它已被覆盖并且丢失了。【参考方案2】:只需将当前的 setting.gradle 文件代码替换为您要运行的版本项目 setting.gradle。 例如: 其他版本项目: android>setting.gradle
此代码将是您当前的 Flutter 版本,只需将您的 setting.gradle 替换为旧项目或其他项目
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
【讨论】:
欢迎来到 ***。最好将代码作为文本包含在此处,而不是作为图像发布。 @Sahibzada Siraj,您的建议帮助我解决了我的问题。谢谢。【参考方案3】:只需降级你最近使用的库/包,你就可以了
【讨论】:
【参考方案4】:将频道从 stable 更改为 master 对我有用。
查看频道:
flutter channel
更换频道:
flutter channel <channel_name>
例如flutter channel master
【讨论】:
以上是关于运行应用程序时出现错误“$flutterSdkpath\packages\flutter_tools\gradle\app_plugin_loader.gradle”的主要内容,如果未能解决你的问题,请参考以下文章