【错误记录】Flutter 报错 ( Could not read script ‘xxx\flutter_tools\gradle\app_plugin_loader.gradle‘ )(一)

简介: 【错误记录】Flutter 报错 ( Could not read script ‘xxx\flutter_tools\gradle\app_plugin_loader.gradle‘ )(一)

文章目录

一、 报错信息

二、 问题分析

三、 解决方案





一、 报错信息


问题环境描述 : 在 电脑 A 上创建了 Flutter 应用 , 上传到了 GitHub 中 , 然后在 电脑 B 上下载该源码 , 编译时报如下错误 ;


FAILURE: Build failed with an exception.
* Where:
Settings file 'D:\002_Project\002_Android_Learn\flutter_photo\android\settings.gradle' line: 11
* What went wrong:
A problem occurred evaluating settings 'android'.
> Could not read script 'D:\001_Programs\004_Flutter\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 1s
Running Gradle task 'assembleRelease'...                            3.1s
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1



image.png





二、 问题分析


问题核心错误 :


Could not read script 
'D:\001_Programs\004_Flutter\flutter\packages\flutter_tools\gradle\app_plugin_loader.gradle' 
as it does not exist.


编译时需要 D:\001_Programs\004_Flutter\flutter\packages\flutter_tools\gradle\app_plugin_loader.gradle 文件 , 我在 D:\001_Programs\004_Flutter\flutter\packages\flutter_tools\gradle\ 目录下没有找到 app_plugin_loader.gradle 文件 ;


image.png


查看该出现问题的 android/setting.gradle 文件 ;


include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"


在本电脑上可运行的其它应用的 android/setting.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
}




电脑 B 上创建的 Flutter 工程可以在 电脑 A 上运行 ;

电脑 A 上创建的 Flutter 工程不能在 电脑 B 上运行 ;

怀疑是环境版本 , Flutter 版本 , Dart 版本 , Android Studio 版本 , Android SDK 版本 不一致导致的 ;

建议全部使用相同的配置 ;


目录
相关文章
|
1月前
|
JSON 小程序 JavaScript
uni-app开发微信小程序的报错[渲染层错误]排查及解决
uni-app开发微信小程序的报错[渲染层错误]排查及解决
498 7
|
14天前
|
存储 测试技术 Shell
Flutter UT太多导致跑覆盖率报错
Flutter UT太多导致跑覆盖率报错
25 2
|
20天前
|
C#
【Azure App Service】使用Microsoft.Office.Interop.Word来操作Word文档,部署到App Service后报错COMException
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).
|
3月前
【Azure Logic App】使用Outlook.com发送邮件遇到429报错
【Azure Logic App】使用Outlook.com发送邮件遇到429报错
|
3月前
|
开发工具 git
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
|
3月前
|
开发框架 .NET Windows
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
|
3月前
|
缓存
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
|
3月前
|
JavaScript API
Vue3 运行可以,build 打包发布报错,app.config.globalProperties 用法坑
Vue3 运行可以,build 打包发布报错,app.config.globalProperties 用法坑
87 2
|
3月前
|
开发工具 iOS开发
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
144 2
|
3月前
|
JSON 自然语言处理 Android开发
Flutter本地化(国际化)之App名称
Flutter本地化(国际化)之App名称
68 1
下一篇
无影云桌面