近年来随着Android Studio 升级以及Android Studio 内如继承了JRE 原先我们一些需要调用jdk内部工具的方法 现在zai Android Studio中能简单的实现了.
这里我们就实现简单的获取项目中签名的SHA1 MD5 SHA256
实现:
1.配置 bulid.gradle (app目录下的)
plugins {
id 'com.android.application'
id 'kotlin-android'
}
static def stringValue(def value) {
return "\"${value}\""
}
android {
compileSdkVersion = 30
buildToolsVersion = "30.0.3"
defaultConfig {
applicationId "com.wu.material"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
ndk {
// 设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
abiFilters "armeabi-v7a"
}
}
signingConfigs {
debug {
storeFile file("../material.keystore")
storePassword '123456'
keyAlias 'material'
keyPassword '123456'
}
release {
storeFile file("../material.keystore")
storePassword '123456'
keyAlias 'material'
keyPassword '123456'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
zipAlignEnabled true
debuggable = true
buildConfigField "String", "APP_WECHAT_KEY", stringValue("wx61ac9619cdafdbd8")
}
release {
signingConfig signingConfigs.release
zipAlignEnabled true
debuggable = false
buildConfigField "String", "APP_WECHAT_KEY", stringValue("wx61ac9619cdafdbd8")
}
}
//输出包
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "material-${variant.versionName}-${variant.name}.apk"
}
}
repositories {
flatDir {
dirs "lib"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
dataBinding = true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation "androidx.lifecycle:lifecycle-viewmodel:2.4.0"
implementation "androidx.multidex:multidex:2.0.0"
implementation 'com.github.bumptech.glide:glide:4.13.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
//携程
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
implementation 'com.google.code.gson:gson:2.8.6'
//指针
implementation 'com.github.hackware1993:MagicIndicator:1.5.0'
//定位
implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8'
//地图
implementation 'com.baidu.lbsyun:BaiduMapSDK_Map:7.4.0'
implementation 'com.baidu.lbsyun:BaiduMapSDK_Search:7.4.0'
implementation 'com.baidu.lbsyun:BaiduMapSDK_Util:7.4.0'
}
bulid.gradle.png
2.2. 执行 bulid.gradle 的 signingReport 任务 获取SHA1 MD5 SHA256
image.png总结
嘿嘿简单的方法获取了项目SHA1 MD5 SHA256 万恶的小黑窗口 say goodbye !!!
网友评论