【问题标题】:Error when generate Gradle Wrapper files生成 Gradle Wrapper 文件时出错
【发布时间】:2018-08-08 16:24:56
【问题描述】:

我在 ubuntu 中有一个 react native 项目,我想生成 Gradle Wrapper 文件,所以我安装了 gradle 并在 android/app 中运行了这个命令

gradle wrapper --gradle-version 3.4.1

但是当我运行这个命令时,我得到了这个错误

FAILURE: Build failed with an exception.

* Where:
Build file '/var/MY_PROJECT/android/app/build.gradle' line: 122

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'release' for SigningConfig container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

【问题讨论】:

  • 能否分享一下 build.gradle 文件。
  • 谢谢@LazerBass我解决了我的问题

标签: android ubuntu react-native gradle gradlew


【解决方案1】:

我的问题发生是因为我没有定义它就调用了SigningConfig

所以我通过在/var/MY_PROJECT/android/app/build.gradle 中定义SigningConfig 解决了这个问题

...
android {
  ...
  defaultConfig { ... }
  signingConfigs {
    release {
      if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
        storeFile file(MYAPP_RELEASE_STORE_FILE)
        storePassword MYAPP_RELEASE_STORE_PASSWORD
        keyAlias MYAPP_RELEASE_KEY_ALIAS
        keyPassword MYAPP_RELEASE_KEY_PASSWORD
      }
    }
  }
  buildTypes { ... }
}
...

如果您想了解有关如何将签名配置添加到应用的 gradle 配置的更多信息,请点击 here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-21
    相关资源
    最近更新 更多