Why are there two build.gradle files in an Android Studio project?(为什么一个 Android Studio 项目中有两个 build.gradle 文件?)
问题描述
将 Eclipse 项目导入 Android Studio 后,我看到两个 build.gradle
文件:
After having imported an Eclipse project into Android Studio, I see two build.gradle
files:
1 - <PROJECT_ROOT>uild.gradle
2 - <PROJECT_ROOT>appuild.gradle
第一个版本较短,第二个版本包含compileSdkVersion
等的定义.
The first version is shorter, the second version contains definitions for compileSdkVersion
, etc.
拥有两个独立文件的目的是什么?是否有单独的构建任务?
What is the purpose behind having two separate files? Are there separate build tasks?
推荐答案
<PROJECT_ROOT>appuild.gradle
专用于 app 模块.
<PROJECT_ROOT>uild.gradle
是一个顶级构建文件",您可以在其中添加所有子项目/模块通用的配置选项.
<PROJECT_ROOT>uild.gradle
is a "Top-level build file" where you can add configuration options common to all sub-projects/modules.
如果您在项目中使用另一个模块,作为本地库,您将拥有另一个 build.gradle
文件:<PROJECT_ROOT>moduleuild.gradle
If you use another module in your project, as a local library you would have another build.gradle
file:
<PROJECT_ROOT>moduleuild.gradle
对于顶级文件中的 example,您可以指定以下常用属性:
For example in your top level file you can specify these common properties:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
ext {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
}
在你的 appuild.gradle
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
这篇关于为什么一个 Android Studio 项目中有两个 build.gradle 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么一个 Android Studio 项目中有两个 build.gradl
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01