【问题标题】:android studio use sync project with gradle files actionandroid studio 使用带有 gradle 文件操作的同步项目
【发布时间】:2017-04-30 17:53:08
【问题描述】:

我想在命令行中使用 sync project with gradle file 但我不知道该怎么做

像这样:

它除了做./gradlew build还做其他事情

例如在一个文件中写入一个本地库名android-test 比在 settings.gradle 中读取此文件并调用 include ":${android-test}" 。如果我使用 AS sync project with gradle files 按钮,AS 可以加载 模块到 project ,但是当我运行 ./gradlew build 时,它不起作用。

但是我开发了一个插件,我想用这个动作,那么这个函数怎么调用呢?

【问题讨论】:

    标签: android android-studio intellij-idea plugins


    【解决方案1】:

    Building and syncing from the command line 真的很简单。在项目的根目录中,您可以使用

    调用 gradle 包装器的构建命令
    ./gradlew build
    

    要获取项目的所有可用构建任务的列表:

    ./gradlew tasks
    

    【讨论】:

      【解决方案2】:

      "./gradlew build" 和 "./gradlew tasks" 在你的项目路径中。 更多命令和步骤在这里:https://developer.android.com/studio/build/building-cmdline.html

      【讨论】:

        【解决方案3】:

        action id 是Android.SyncProject,所以你可以在你的插件中调用它:

        ActionManager.getInstance().getAction("Android.SyncProject").actionPerformed(e);
        

        你可以在android-plugin.xml找到它,也许是161行。

        您也可以在SyncProjectAction.java36 行中找到它的文字。

        【讨论】:

          猜你喜欢
          • 2015-07-30
          • 2013-11-24
          • 1970-01-01
          • 2022-01-19
          • 2014-07-03
          • 2014-04-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多