我已经回顾了很多有关此主题的帖子,
首发。但我仍然无法通过第69行的Gradle错误Error:(69, 0) Could not find method storeFile() for arguments [/path/to/my.keystore]
:
storeFile file(keystoreProperties['storeFile'])
模块gradle构建文件中的- 我的模块gradle.build文件的内容:
apply plugin: 'com.android.application'
apply plugin: 'signing'
android {
...
buildTypes {
...
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
}
...
}
...
}
...
我加载keystore.properties
文件(位于项目根目录中),其中包含:
storeFile=/path/to/my.keystore
storePassword=storepwd
keyPassword=keypwd
keyAlias=keyalias
如您所见,我在gradle.build文件的storeFile引用中有一个文件构造函数,在属性文件中有一个keystore的路径。
错误在哪里,或者我错过了什么,不理解?
参考
答案 0 :(得分:11)
您必须在不在signing
区块中的buildTypes
区块中添加此DSL。
signingConfigs {
release {
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
}
}