Android Studio開發之Gradle配置格式化---基礎版

序言:

今天發現原來Gradle配置還有這麼高級的玩法,記錄一下,以備忘!備註:我使用的Android Studio版本是3.0.1

正文:

利用build.gradle文件和gradle.properties兩個文件實現的!

1、gradle.properties文件在工程根目錄下!給出我的示例:

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# Jimmy-format ######################################################################################
COMPILE_SDK_VERSION=26
APPLICATION_ID=com.terawins.www.jni_file_demo2
MIN_SDK_VERSION=15
TARGET_SDK_VERSION=26
VERSION_CODE=1
VERSION_NAME=1.0
#NDK
Support_CPU=armeabi-v7a
MK_FilePath=src/main/jni/Android.mk
#others
TEST_Instrumentation_Runner=android.support.test.runner.AndroidJUnitRunner
Lib_SupportAppcompat_v7=com.android.support:appcompat-v7:26.1.0
Lib_SupportConstraintLayout=com.android.support.constraint:constraint-layout:1.1.3
Lib_Junit=junit:junit:4.12
Lib_SupportTestRunner=com.android.support.test:runner:1.0.1
Lib_SupportTestEspresso=com.android.support.test.espresso:espresso-core:3.0.1
#####################################################################################################

截圖如下:

2、build.gradle文件是app目錄下的那個build.gradle文件。給出我的示例:

apply plugin: 'com.android.application'

android {
    compileSdkVersion COMPILE_SDK_VERSION as int
    defaultConfig {
        applicationId APPLICATION_ID
        minSdkVersion MIN_SDK_VERSION as int
        targetSdkVersion TARGET_SDK_VERSION as int
        versionCode VERSION_CODE as int
        versionName VERSION_NAME
        testInstrumentationRunner TEST_Instrumentation_Runner
        ndk{
            abiFilters Support_CPU
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild{
        ndkBuild{
            path MK_FilePath
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation Lib_SupportAppcompat_v7
    implementation Lib_SupportConstraintLayout
    testImplementation Lib_Junit
    androidTestImplementation Lib_SupportTestRunner
    androidTestImplementation Lib_SupportTestEspresso
}

截圖如下:

 

---- The End.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章