查看keystore别名等信息
keytool -list -v -keystore C:\Users\name\.android\debug.keystore -storepass android
解释 : keytool -list -v -keystore xxx.keystore/yyy.jks的绝对路径 -storepass 签名文件的密码。
查看android自带的 debug.keystore ,签名文件的密码是android ; 别名是: androiddebugkey 。
替换debug.keystore
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.xxx"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
storeFile file("../mydebug.keystore") //在与module同级的路径下添加mydebug.keystore。
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
debug { //debug模式下
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
release {//打包生成正式发行签名apk时调用。
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:24.1.0'
compile 'com.android.support:recyclerview-v7:24.1.0'
compile 'com.android.support:cardview-v7:24.1.0'
}
在未用Build工具生成签名apk之前,所有的运行都是debug模式。
debug模式
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
release模式:手动调用Build工具生成签名APK。
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}