When following the steps at https://developer.android.com/studio/build/gradle-tips#remove-private-signing-information-from-your-project, I get the following error and the Cordova Android app does not build:
/platforms/android/build.gradle': 82: Invalid variable name. Must start with a letter but was: ‘proguard
Line 82 is:
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
I don't know what the error is referring to. I don't see any variables beginning with anything other than letters. The build.gradle file includes:
// 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’
}
}
}
The problem is the curly quotes in
‘proguard-rules.pro’Curly quotes are not recognized by Gradle, so it's enough to change them to normal single quotes:
'proguard-rules.pro'.Most occurrences of this error are caused by weird quotes or invisible characters that can be hard to spot. They can be fixed using simple online tools: