Android Studio中統(tǒng)一管理版本號(hào)引用配置問題
方式一:
在gradle.properties中寫入:
#測(cè)試環(huán)境 ENV_TEST=test #開發(fā)環(huán)境 ENV_DEV=dev #生產(chǎn)環(huán)境 ENV_ONLINE=online APPLICATION_ID=com.xxx.xxxx COMPILE_SDK_VERSION=26 TARGET_SDK_VERSION=26 MIN_SDK_VERSION=15 SUPPORT_V4_SUPPORT=com.android.support:support-v4:26.1.0 SUPPORT_ANNOTATIONS=com.android.support:support-annotations:26.1.0 SUPPORT_V7_APPCOMPAT=com.android.support:appcompat-v7:26.1.0 SUPPORT_V7_RECYCLERVIEW=com.android.support:recyclerview-v7:26.1.0
使用規(guī)則,字符串直接用,整形需在后加 as int
android { compileSdkVersion COMPILE_SDK_VERSION as int defaultConfig { applicationId APPLICATION_ID minSdkVersion MIN_SDK_VERSION as int targetSdkVersion TARGET_SDK_VERSION as int versionCode 100 versionName "1.0.0" multiDexEnabled true flavorDimensions "versionCode" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
方式二:
在根目錄下的build.gradle文件下添加 buildscript{ .... } 中的內(nèi)容:
buildscript { ext.kotlin_version = '1.1.51' ext.rxandroid = '2.0.1' ext.anko_version = '0.8.2' ext.support_version = '26.1.0' ext.target_sdk_version = 26 ext.min_sdk_version = 15 ext.applicationId = 'com.beiyijinfu.rxbusdemo' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
使用規(guī)則,字符串需使用“$”,整形直接用
android { compileSdkVersion compile_sdk_version defaultConfig { applicationId "com.xxx.xxxx" minSdkVersion min_sdk_version targetSdkVersion target_sdk_version versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation "com.android.support:appcompat-v7:$support_version" implementation "io.reactivex.rxjava2:rxandroid:$rxandroid" implementation "org.jetbrains.anko:anko-common:$anko_version" implementation "com.android.support:recyclerview-v7:$support_version" }
方式三:
在根目錄下的build.gradle文件下添加 ext{ .... } 中的內(nèi)容:
ext{ kotlin_version = '1.1.51' rxandroid = '2.0.1' anko_version = '0.8.2' support_version = '26.1.0' target_sdk_version = 26 compile_sdk_version = 26 min_sdk_version = 15 }
使用規(guī)則,字符串需使用“$rootProject.”,整形直接用rootProject.。ext可加可不加
android { compileSdkVersion rootProject.compile_sdk_version defaultConfig { applicationId "com.xxx.xxxx" minSdkVersion rootProject.ext.min_sdk_version targetSdkVersion rootProject.ext.target_sdk_version versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlin_version" implementation "com.android.support:appcompat-v7:$rootProject.support_version" implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroid" compile "org.jetbrains.anko:anko-common:$rootProject.anko_version" compile "com.android.support:recyclerview-v7:$rootProject.support_version" }
方式四:
在項(xiàng)目根目錄下創(chuàng)建.gradle文件,如:config.gradle,config.gradle中文件內(nèi)容可以自己定義,如下示例:
ext{ kotlin_version = '1.1.51' rxandroid = '2.0.1' anko_version = '0.8.2' support_version = '26.1.0' target_sdk_version = 26 compile_sdk_version = 26 min_sdk_version = 15 }
使用規(guī)則,在build.gradle中先引用進(jìn)來:
apply from :"config.gradle" dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile "com.android.support
總結(jié)
以上所述是小編給大家介紹的Android Studio中統(tǒng)一管理版本號(hào)引用配置問題,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Android實(shí)現(xiàn)自定義滑動(dòng)刻度尺方法示例
這篇文章主要給大家介紹了關(guān)于Android實(shí)現(xiàn)自定義滑動(dòng)刻度尺的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)各位Android開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04詳解Activity之singletast啟動(dòng)模式及如何使用intent傳值
在一個(gè)新棧中創(chuàng)建該Activity實(shí)例,并讓多個(gè)應(yīng)用共享改棧中的該Activity實(shí)例。一旦改模式的Activity的實(shí)例存在于某個(gè)棧中,任何應(yīng)用再激活改Activity時(shí)都會(huì)重用該棧中的實(shí)例,其效果相當(dāng)于多個(gè)應(yīng)用程序共享一個(gè)應(yīng)用,不管誰激活該Activity都會(huì)進(jìn)入同一個(gè)應(yīng)用中2015-11-11Android TextView顯示Html類解析的網(wǎng)頁和圖片及自定義標(biāo)簽用法示例
這篇文章主要介紹了Android TextView顯示Html類解析的網(wǎng)頁和圖片及自定義標(biāo)簽用法,實(shí)例分析了Android中TextView控件的使用技巧,需要的朋友可以參考下2016-07-07Android ListView實(shí)現(xiàn)無限循環(huán)滾動(dòng)
這篇文章主要為大家詳細(xì)介紹了Android ListView實(shí)現(xiàn)無限循環(huán)滾動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06Android時(shí)間日期拾取器學(xué)習(xí)使用(DatePicker、TimePicker)
這篇文章主要為大家詳細(xì)介紹了Android提供的DatePicker日期拾取器和TimePicker時(shí)間拾取器的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02Android?MaterialAlertDialogBuilder修改按鈕屬性
這篇文章主要介紹了Android?MaterialAlertDialogBuilder修改按鈕屬性實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11關(guān)于Android?Webview?設(shè)置Cookie問題詳解
大家好,本篇文章是關(guān)于Android?Webview?設(shè)置Cookie問題詳解,感興趣的同學(xué)可以看看,希望對(duì)你起到幫助,有用的話記得收藏,方便下次瀏覽2021-11-11NestScrollView嵌套R(shí)ecyclerView實(shí)現(xiàn)淘寶首頁滑動(dòng)效果
這篇文章主要介紹了NestScrollView嵌套R(shí)ecyclerView實(shí)現(xiàn)淘寶首頁滑動(dòng)效果,主要實(shí)現(xiàn)淘寶首頁嵌套滑動(dòng),中間tab吸頂效果,以及介紹NestScrollView嵌套R(shí)ecyclerView處理滑動(dòng)沖突的方法,需要的朋友可以參考下2021-12-12Android實(shí)現(xiàn)點(diǎn)擊縮略圖放大效果
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)點(diǎn)擊縮略圖放大效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09