一仿滔、首先我們?cè)陧?xiàng)目根目錄建立一個(gè)project.properties自定義的簽名相關(guān)信息:
key.file=../filename.keystore
keyAlias=filealias
keyPassword=123456
storePassword=123456
二拳昌、然后在module的gradle中定義如下內(nèi)容:
signingConfigs {
debug {
//加載資源
Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('project.properties').newDataInputStream() ;
properties.load( inputStream )
//讀取文件
def sdkDir = properties.getProperty('key.file')
//讀取字段
def key_keyAlias = properties.getProperty( 'keyAlias' )
def key_keyPassword = properties.getProperty( 'keyPassword' ) ;
def key_storePassword = properties.getProperty( 'storePassword' ) ;
storeFile file(sdkDir)
storePassword key_storePassword
keyAlias key_keyAlias
keyPassword key_keyPassword
}
/* release {
storeFile file( sdkDir )
storePassword key_storePassword
keyAlias key_keyAlias
keyPassword key_keyPassword
}*/
}
當(dāng)然這樣做的最終目的是為了防止簽名信息暴露,最后不要把簽名文件放到項(xiàng)目下烟号,而是類(lèi)似C:\work\Key.jks這樣