android - 生成 Gradle Wrapper 文件时出错

标签 android ubuntu react-native gradle gradlew

我在 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

最佳答案

我的问题发生是因为我在没有定义的情况下调用了 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 { ... }
}
...

if you want learn more about how to adding signing config to your app's gradle config click here

关于android - 生成 Gradle Wrapper 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51728655/

相关文章:

python - 找不到真正的 FFmpeg 安装(ffprobe 自带)

linux - 全新安装后 PostgreSQL "cannot access the server configuration file (...) No such file or directory"

node.js - 无法在 react native 教程中启动 npm

java - 更新 Firestore 集合中找到的所有文档中的字符串字段

android - TextInputLayout 提示颜色

django - 在 apache2 服务器上运行的 django 站点的 'correct' 权限设置是什么

reactjs - 无法关闭从父组件触发的模式

javascript - React Native-与Android Studio编译 bundle

javascript - Firebase 消息传递和身份验证相结合来设置自定义 token

android - 在 Google Maps Android V2 中聚类大量标记时的最佳实践