按照https://developer.android.com/studio/build/gradle-tips#remove-private-signing-information-from-your-project上的步骤时,我收到以下错误并且 Cordova Android 应用程序无法构建:
/platforms/android/build.gradle': 82: Invalid variable name. Must start with a letter but was: ‘proguard
第 82 行是:
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
我不知道错误指的是什么。我没有看到任何以字母以外的任何东西开头的变量。build.gradle 文件包括:
// Creates a variable called keystorePropertiesFile, and initializes it to the
// keystore.properties file.
def keystorePropertiesFile = rootProject.file("keystore.properties")
// Initializes a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()
// Loads the keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
// https://developer.android.com/studio/build/gradle-tips#remove-private-signing-information-from-your-project
android {
buildTypes {
signingConfigs {
config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
// you will normally want to enable ProGuard only for your release
// builds, as it’s an additional step that makes the build slower and can make debugging more difficult
release {
minifyEnabled true
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
}