1.建立jks文件。
此处省略
2.在app module,build.gradle中做配置。
plugins {
id 'com.android.application'
}
def getTime() {
return new Date().format("yyyyMMddHHmmSS", TimeZone.getDefault());
}
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.simple.automatedtesting"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias 'automatetesting'
keyPassword '123456789'
storeFile file('/home/wangyetao/AndroidstudioProjects/automatedtesting/app/jks/key_automatetesting.jks')
storePassword '123456789'
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "app-automatedtesting-release-v" + defaultConfig.versionName + getTime() + ".apk"
outputFileName = fileName
}
}
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation files('libs/fastjson-1.2.49.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation files('libs/fastjson-1.2.49.jar')
}
3.使用androidstudio生成包,包生成格式效果如下。
app-automatedtesting-release-v1.0202110080207811.apk