zoukankan      html  css  js  c++  java
  • Android Studio 和 Gradle

    由于以前没做过什么java项目,在使用Android Studio时遇到了Gradle,真是一头雾水,决定总结一下。

    具体的使用方法请参看:http://www.cnblogs.com/youxilua/p/3348162.html

    --------------------------------------------------------------------------------------------------------------------------------

    什么是构建工具?其实就是build工具,在软件开发中用来将源代码和其他输入文件转换为可执行文件的形式(也有可能转换为可安装的产品映像形式)。随着应用程序的生成过程变得更加复杂,确保在每次生成期间都使用精确相同的生成步骤,同时实现尽可能多的自动化,以便及时产生一致的生成版本。类似Unix/Linux C程序员经常使用的Make工具,但是提供了许多新功能,来弥补Makefiles的不足

    看看以下来自http://www.oschina.net/question/558461_117208 的解释

    一般而言.一个比较正规的项目都不会基于IDE 进行构建..一般会用ant, maven, gradle , 
    为什么不用ide 呢?首先,是ide的选择,有人喜欢,用vim,eclipse,intellijidea,收费的,免费的. 
    
    特别是公开的项目,你用什么IDE 相当于为这个IDE 打广告了.. 
    
    所以,一般而言都是用构建工具,而不是IDE .实际上各种IDE 也是基于各种构建系统,也正是不同的IDE,它们的构建方式不同,所以要让不同的IDE间能一起开发,于是需要一个统一的构建工具,只是你平时不关注而已.. 
    
    扯到构建工具, 一般c/c++ 项目用make,或者 premake. 而java 一般是ant,ivy,gradle,maven,还有直接的shell, 是不是很多没听说过呢? 

    这里没有提到xcode使用的构建工具,我想它应该使用了一套自己的构建方法,也算一种IDE自带的构建。 

    来看一下Android Studio中的Gradle截图,

    其实,就是一系列的build步奏。

    --------------------------------------------------------------------------------------------------------------------------------

    1. 在Android开发中常用的构建工具

    There are two types of Android projects that work in Android Studio:

    • Gradle-based projects. These are created by default.
    • IntelliJ "classic" projects. These cannot be created in Studio, but when they are created in IntelliJ, they can be opened in Studio.

    In Android Studio, we are focusing all of our efforts on the Gradle-based projects, both in terms of feature development and in testing. If you are using Studio, we strongly recommend you use Gradle-based projects. If you prefer IntelliJ projects, you might want to use IntelliJ: The Android support in Studio, including the gradle support, is also all available in IntelliJ.

    简单的说,用Studio创建出的全是使用gradle构建工具的工程,而使用IntelliJ IDEA 这个IDE,可以创建IntelliJ "classic" projects。这种"classic" projects的构建工具是什么?

    Gradle based projects offer significant features for Android development.
    • Support for binary libraries (AARs). You no longer need to copy library sources (such as ActionBarSherlock) into your own projects, you can simply declare a dependency and the library is automatically downloaded and merged into your project. This includes automatically merging in resources, manifest entries, proguard exclusion rules, custom lint rules etc at build time.
    • Support for variants and build types. This makes it trivial to for example offer different versions of your app such as a free version and a "pro" version.
    • Easy build configuration and customization. For example, you can pull version names and version codes from git tags as part of the build.
    • Gradle can be used from the IDE but also from the command line and from CI servers like Jenkins, providing the same build everywhere, every time.

    2.在Android Studio中使用Gradle

    请参见官方文档 Gradle Plugin User Guide

  • 相关阅读:
    CSS
    HTML
    MySQL:PyMySQL&ORM
    MySQL:SQL进阶
    03-body标签中相关标签
    02-body标签中相关标签
    01-html介绍和head标签
    并发编程
    异常处理、网络编程
    面向对象进阶和模块
  • 原文地址:https://www.cnblogs.com/breezemist/p/3491173.html
Copyright © 2011-2022 走看看