什么是真正的 Android Studio Gradle 版本? [英] What is the real Android Studio Gradle Version?

查看:28
本文介绍了什么是真正的 Android Studio Gradle 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在(根)build.gradle Gradle 版本是 3.1.3.

(Root) build.gradle

buildscript {存储库{谷歌()jcenter()}依赖{类路径 'com.android.tools.build:gradle:3.1.3'//注意:不要将您的应用程序依赖项放在这里;他们属于//在单独的模块 build.gradle 文件中}}

project-structure 中,Gradle 版本是 4.4

项目结构

Gradle 4.4 版

在 Gradle-wrapper-properties 的 distributionUrl 中,Gradle 版本是 4.4

Gradle-Wrapper-Properties

#Tue Jul 17 17:49:20 KST 2018distributionBase=GRADLE_USER_HOME分布路径=包装器/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

但我可以构建并在智能手机中运行应用程序.

什么是真正的 Gradle 版本?

解决方案

你需要清楚这里三个的事情:

  • 摇篮
  • Android Gradle 插件
  • Gradle 包装器

具体来说,

  • Gradle 是一种独立于 Android 发展的构建工具.从理论上讲,Gradle 可以用于构建任何类型的项目,例如典型的 Java 项目、Android 项目甚至 iOS 项目.它还可以与任何类型的 IDE 集成,例如,

    例如,Android Gradle 插件版本 3.1.0+ 需要最低的 Gradle 版本 4.4,可以通过 Android Studio 进行配置.

  • Gradle 包装器.根据官方文档Gradle Wrapper

    <块引用>

    执行任何 Gradle 构建的推荐方法是借助 Gradle Wrapper(简称Wrapper").Wrapper 是一个调用 Gradle 声明版本的脚本,如有必要,可以提前下载它.因此,开发人员可以快速启动并运行 Gradle 项目,而无需遵循手动安装流程,从而为您的公司节省时间和金钱.

    这个包装器可以从你的项目目录下的 gradle-wrapper.properties 配置.例如,

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

    或者从您的问题中所说的 Android Studio GUI:

    .

In (Root) build.gradle Gradle Version is 3.1.3.

(Root) build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

In project-structure the Gradle version is 4.4

Project-Structure

Gradle version 4.4

In Gradle-wrapper-properties distributionUrl's, the Gradle version is 4.4

Gradle-Wrapper-Properties

#Tue Jul 17 17:49:20 KST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

But I can build and I can run the application in the smartphone.

What is the real Gradle version?

解决方案

You need to be clear about three things here:

  • Gradle
  • Android Gradle Plugin
  • Gradle Wrapper

Specifically speaking,

  • Gradle is a build tool which evolves independently of Android. Theoretically, Gradle can be used to build any kind of project, for example, a typical Java project, Android Project and even iOS project. It can also be integrated with any kind of IDE, for example, Android Studio, NetBeans, or Eclipse.

    By the time of writing, the latest Gradle version is 4.9, and you can always check its current version from Gradle installation guide. One of the great features of Gradle build tool is it supports Custom Plugins.

  • Android Gradle Plugin The Android Gradle Plugin is one such Gradle custom plugin. For the typical Android project, the version of this plugin can be configured in the top-level build.gradle.

    buildscript {
        ....
            dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
        }
        ....
    }
    

    For each version of this plugin, it requires a minimum Gradle version as listed in this page gradle-plugin or see below mapping table for a quick information:

    For example, Android Gradle Plugin version 3.1.0+ requires a minimal Gradle version 4.4 which can be configured via Android Studio.

  • Gradle Wrapper. According to the official document Gradle Wrapper

    The recommended way to execute any Gradle build is with the help of the Gradle Wrapper (in short just "Wrapper"). The Wrapper is a script that invokes a declared version of Gradle, downloading it beforehand if necessary. As a result, developers can get up and running with a Gradle project quickly without having to follow manual installation processes saving your company time and money.

    This wrapper can be configured from gradle-wrapper.properties under your project directory. For example,

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
    

    Or from the Android Studio GUI as said in your question:

    .

这篇关于什么是真正的 Android Studio Gradle 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆