问题描述
当前,我在尝试构建Flutter项目(flutter运行)时收到"已完成错误:Gradle任务组装调试失败,退出代码为1 ".日志没有太大帮助.因此,我想使用stacktrace选项手动运行" gradlew构建"或类似的命令,以查看幕后情况.这是什么命令?
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存储库并安装Pod)
(update the pod repo and install the pods)
简短的提醒一下,如果要从本机文件夹创建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.
这篇关于如何在Flutter项目上手动运行Gradle构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!