How to run gradle build manually on a flutter project

狂风中的少年 提交于 2020-02-16 04:25:33

问题


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 ?


回答1:


For posterity I will post my comment as an answer too and I'll elaborate it a bit.

When you create a flutter project there are two new folders created inside the main folder, one is android and one is ios.

The android folder contains the Android native code and all the android configurations, you can handle it as a native android project.

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.

So for Android you could do:

    cd android/
    ./gradlew clean
    ./gradlew build

(clean and build the project)

For iOS you could do:

   cd ios/
   pod repo update
   pod install

(update the pod repo and install the pods)

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.



来源:https://stackoverflow.com/questions/58911463/how-to-run-gradle-build-manually-on-a-flutter-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!