【问题标题】:What happens after I run rebuild project in Android Studio?在 Android Studio 中运行重建项目后会发生什么?
【发布时间】:2015-06-05 09:01:57
【问题描述】:

文档http://www.jetbrains.com/idea/help/rebuilding-project.html?search=reb 只告诉我如何重建项目。

我不知道重建项目是什么意思(Menu --> Build --> Rebuild Project),它会清除所有编辑缓存吗?运行重建项目后,我发现项目的大小减小了?

在Android Studio中清空一个项目是什么意思?

【问题讨论】:

    标签: android android-studio android-gradle-plugin


    【解决方案1】:

    在 Android Studio 中,构建菜单中的几乎每个声音都映射到一个(可能不止一个)gradle 操作,其中 Gradle 是 android 的官方构建系统。特别是,当您清理项目时,您将从应用程序模块内的 build 文件夹中删除一些文件,并且当您选择重新构建时,这相当于执行 gradle clean 和 build。 有关该主题的更多信息,我建议您在 Udacity 上进行此课程,您可以免费查看。它教你 gradle 以及它如何与 android studio 集成。

    https://www.udacity.com/course/gradle-for-android-and-java--ud867

    【讨论】:

    • 致flower_green:你给我一个关于重建项目的链接吗?我在udacity.com/course/gradle-for-android-and-java--ud867 找不到它。谢谢!
    • 我找不到专门关于重建项目的链接,但正如课程中所说,我认为你最好的选择是单击重建项目并查看在 gradle 控制台窗口中执行了哪些 gradle 任务安卓工作室。当您点击rebuild时,会执行以下三个任务:[clean, :app:compileDebugSources, :app:compileDebugAndroidTestSources],其中最后两个的名称根据版本类型和当前风格而变化。在这里您可以找到有关已执行任务的更多信息:tools.android.com/tech-docs/new-build-system/…
    【解决方案2】:

    Android App 是一个使用com.android.application 插件的Gradle 项目。当您单击重建按钮、清理按钮或运行按钮时。它将运行一系列命令。请注意,并非所有命令都是 Gradle 任务。例如,运行和调试按钮将在后台运行adb

    Rebuild 按钮中,您正在运行多个 Gradle 任务。您可以在 Android Studio 的右下角看到它。

    在这种情况下,Android Studio 将运行以下 Gradle 任务: clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources

    您在冒号 (:) 之前看到的是模块名称。 app:generateDebugSource 将在 app 模块上运行 generateDebugSource 任务。

    但是如果你有多个模块会发生什么?

    显然,Android Studio 将在每个模块上运行这些任务。

    Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources, :myandroidlib:generateDebugSources, :myandroidlib:mockableAndroidJar, :myandroidlib:prepareDebugUnitTestDependencies, :myandroidlib:generateDebugAndroidTestSources, :myandroidlib:compileDebugSources, :myandroidlib:compileDebugUnitTestSources, :myandroidlib:compileDebugAndroidTestSources]
    

    它会清除所有编辑缓存吗?我发现项目规模缩小了 在我运行重建项目之后?

    它将清理build 文件夹中的文件。通常,这不包含在项目中(在.gitignore 中添加)。 build 文件夹将包含您的最终 apkR 文件、报告文件(如 lint / JUnit 测试报告)和生成的类(来自 Dagger / Retrofit)。这就是为什么它会减少你的项目的大小。

    顺便说一句,在Android studio中清除项目是什么意思?

    如果您所说的clear projectclean project

    Android Studio 将运行以下这些任务,这实际上会删除 build 文件夹。

    Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :myandroidlib:generateDebugSources, :myandroidlib:mockableAndroidJar, :myandroidlib:prepareDebugUnitTestDependencies, :myandroidlib:generateDebugAndroidTestSources]

    【讨论】:

      猜你喜欢
      • 2020-09-07
      • 1970-01-01
      • 2016-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      相关资源
      最近更新 更多