[笔记] Android开发中的gradle是什么?

  • gradle是什么?

先看下文档中的介绍   https://docs.gradle.org/current/userguide/what_is_gradle.html

Gradle is an open-source build automation tool that is designed to be flexible enough to build almost any type of software.

gradle是开源的自动编译工具,可以方便自由的编译任何软件。

 

然后进行了一些笼统的介绍,其中提到了一些需要注意的地方,贴出来如下,感觉这个提醒短期内也用不到。

The most notable restriction is that dependency management currently only supports Maven- and Ivy-compatible repositories and the filesystem.

最需要注意的一点是依赖包管理目前只支持Maven- and Ivy-compatible repositories and the filesystem。

 

  • 用gradle编译一个Android实例

参考https://docs.gradle.org/current/samples/sample_building_android_apps.html

贴出来如下:

Building Android Apps Sample

This sample shows how a simple Android application written in Java can be built with Gradle. The application was created following the Build your first app guide.

Groovy中gradle的内容为
app/build.gradle :
 
plugins {
    id('com.android.application') version '7.1.1'
}

repositories {
    google()
    mavenCentral()
}

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId 'org.gradle.samples'
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName '1.0'
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

To build the application:

$ ./gradlew build

 

posted on 2022-11-13 16:44  无声烟雨  阅读(84)  评论(0编辑  收藏  举报

导航