【问题标题】:Why do I get the error: 82: Invalid variable name. Must start with a letter but was: ‘proguard为什么会出现错误:82:变量名无效。必须以字母开头,但是是:'proguard
【发布时间】:2020-01-20 23:53:59
【问题描述】:

按照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’
    }
  }
} 

【问题讨论】:

    标签: cordova build.gradle proguard android-keystore cordova-plugin-proguard


    【解决方案1】:

    问题是‘proguard-rules.pro’ 中的花括号

    Gradle 无法识别大括号,因此只需将其更改为普通单引号即可:'proguard-rules.pro'

    大多数出现此错误的原因是怪异的引号或难以发现的不可见字符。可以使用简单的在线工具修复它们:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-06
      • 2018-04-23
      • 2020-04-04
      • 1970-01-01
      • 2010-09-12
      • 2015-03-17
      • 1970-01-01
      相关资源
      最近更新 更多