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