如何在颤振项目上手动运行 gradle build [英] How to run gradle build manually on a flutter project
问题描述
目前,我在尝试构建 Flutter 项目(flutter run)时遇到完成错误:Gradle 任务 assembleDebug 失败,退出代码为 1".日志没有多大帮助.因此,我想使用 stacktrace 选项手动运行gradlew build"或类似的东西,看看幕后发生了什么.那个命令是什么?
Currently, I am getting "Finished with error: Gradle task assembleDebug failed with exit code 1" while trying to build a Flutter project (flutter run). The logs do not help much. Therefore, i want to run "gradlew build" or similar manually with stacktrace option to see what is happening under the hood. What is the command for that ?
推荐答案
为了后人,我也会发表我的评论作为答案,我会详细说明一下.
For posterity I will post my comment as an answer too and I'll elaborate it a bit.
当你创建一个flutter项目时,主文件夹内会新建两个文件夹,一个是android
,一个是ios
.
When you create a flutter project there are two new folders created inside the main folder, one is android
and one is ios
.
android
文件夹包含Android原生代码和所有Android配置,您可以将其作为原生Android项目进行处理.
The android
folder contains the Android native code and all the android configurations, you can handle it as a native android project.
ios
文件夹包含 iOS 原生代码和所有 ios 配置,它还包含 xcworkspace
文件,可以像普通 ios 项目一样用 Xcode 打开.
The ios
folder contains the iOS native code and all the ios configurations, it also has the xcworkspace
file which can be opened with Xcode like a normal ios project.
现在您可以在每个文件夹中运行特定于平台的命令,就像我说的,文件夹包含实际的本机项目.
Now you can run platform specific commands in each folder, like i said, the folders contain actual native projects.
因此,对于 Android,您可以这样做:
So for Android you could do:
cd android/
./gradlew clean
./gradlew build
(清理并构建项目)
对于 iOS,你可以这样做:
For iOS you could do:
cd ios/
pod repo update
pod install
(更新 pod repo 并安装 pod)
(update the pod repo and install the pods)
提醒一下,如果你想从 native 文件夹创建 apk/ipa,不要忘记在主文件夹中运行 flutter build
,否则你的 apk 中可能会得到过时的代码/ipa.
Just a short reminder, if you want to create apk/ipa from the native folders, don't forget to run flutter build
in the main folder, otherwise you might get outdated code in your apk/ipa.
这篇关于如何在颤振项目上手动运行 gradle build的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!