Android Studio 无法识别在属性文件中声明的签名配置

Sha*_*tef 7 android android-studio

keystore.properties在根文件夹中有以下密钥存储信息存储

storePassword=******
keyPassword=******
keyAlias=******
storeFile=/home/jerry/jerryKeyStore 
Run Code Online (Sandbox Code Playgroud)

和以下gradle代码来加载它

// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}
Run Code Online (Sandbox Code Playgroud)

当我打开项目结构窗口的签名选项卡时,Android Studio 会读取Unrecognized value所有签名字段。它也无法在我的设备上安装 APK,抛出一个错误,即 APK 是用不同的密钥构建的......因为我使用直接写入 gradle 文件的签名信息构建它

我使用以下
Android Studio:2.1.2
Gradle:2.1.0

Rom*_*rdo 6

确保你有:

buildTypes {
    debug {
        signingConfig signingConfigs.debug
        ......
    }
    release {
        signingConfig signingConfigs.release
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

模块中。