Android build.gradle版本名打包配置的方法
1、生成密鑰文件到app工程目錄下
2、在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 RELEASE_KEY_PASSWORD=key-password RELEASE_KEY_ALIAS=key-alias RELEASE_STORE_PASSWORD=store-password #jks文件名 RELEASE_STORE_FILE=sugr-ivy.jks
3、build.gradle文件下配置
apply plugin: 'com.android.application' android { compileSdkVersion 26 project.archivesBaseName = "AppName" defaultConfig { applicationId "com.example.app" minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.4.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } signingConfigs { release { keyAlias RELEASE_KEY_ALIAS keyPassword RELEASE_KEY_PASSWORD storeFile file(RELEASE_STORE_FILE) storePassword RELEASE_STORE_PASSWORD } debug { keyAlias RELEASE_KEY_ALIAS keyPassword RELEASE_KEY_PASSWORD storeFile file(RELEASE_STORE_FILE) storePassword RELEASE_STORE_PASSWORD } } buildTypes { release { buildConfigField "boolean", "LOG_DEBUG", "false" // 不顯示Log minifyEnabled false //混淆 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release //簽名 } debug { signingConfig signingConfigs.debug //簽名 } } applicationVariants.all { variant -> variant.outputs.all { Calendar calendar = Calendar.getInstance(Locale.CHINA); def buildDate = String.format(Locale.CHINA, "%04d%02d%02d", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH)) def versionName = defaultConfig.versionName def versionCode = defaultConfig.versionCode //android studio3.0之前的寫法 // output->output.outputFile=new File(output.outputFile.parent,output.outputFile.name.replace(".apk","-"+defaultConfig.versionName+".apk")) //android studio3.0的寫法 //項(xiàng)目名-版本名-版本號-release/debug.apk if (variant.buildType.name.equals('release')) { outputFileName = "${project.archivesBaseName}-v${versionName}-c${versionCode}-${buildDate}-release.apk" } else { outputFileName = "${project.archivesBaseName}-v${versionName}-c${versionCode}-${buildDate}-debug.apk" } } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:recyclerview-v7:26.1.0' }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android調(diào)試神器stetho使用詳解和改造
- Android Java調(diào)用自己C++類庫的實(shí)例講解
- Android可自定義神奇動效的卡片切換視圖實(shí)例
- Android添加音頻的幾種方法
- Android線程中Handle的使用講解
- Android傳感器SensorEventListener之加速度傳感器
- Android四大組件之Activity詳解
- Android四大組件之Service詳解
- Android四大組件之BroadcastReceiver詳解
- Android之在linux終端執(zhí)行shell腳本直接打印當(dāng)前運(yùn)行app的日志的實(shí)現(xiàn)方法
相關(guān)文章
RecyclerView無限循環(huán)效果實(shí)現(xiàn)及示例解析
這篇文章主要為大家介紹了RecyclerView無限循環(huán)效果實(shí)現(xiàn)及示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03詳解Android中Activity的四大啟動模式實(shí)驗(yàn)簡述
本篇文章主要介紹了Android中Activity的四大啟動模式實(shí)驗(yàn)簡述,具有一定的參考價值,有興趣的可以了解一下。2016-12-12Android zxing如何識別反轉(zhuǎn)二維碼詳解
這篇文章主要給大家介紹了關(guān)于Android zxing如何識別反轉(zhuǎn)二維碼的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-09-09android開發(fā)教程之文本框加滾動條scrollview
EditText與TextView加上滾動條其實(shí)很簡單,只需要在文本輸入框或者文本顯示框上面加上滾動條控件即可2014-02-02Android自定義View實(shí)現(xiàn)時鐘功能
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)時鐘功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-09-09android中Intent傳值與Bundle傳值的區(qū)別詳解
本篇文章是對android中Intent傳值與Bundle傳值的區(qū)別進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05Android自定義View實(shí)現(xiàn)仿駕考寶典顯示分?jǐn)?shù)效果(收藏)
本文通過自定義view和屬性動畫結(jié)合在一起實(shí)現(xiàn)實(shí)現(xiàn)仿駕考寶典顯示分?jǐn)?shù)效果,非常不錯,具有參考借鑒價值,需要的的朋友參考下2017-03-03Android 實(shí)現(xiàn)抖音頭像底部彈框效果的實(shí)例代碼
這篇文章主要介紹了Android 實(shí)現(xiàn)抖音頭像底部彈框效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04