我在 ubuntu 中有一个 react 本机项目,我想生成 Gradle 包装器文件,所以我安装了 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 { ... }
}
...
如果您想详细了解如何将签名配置添加到应用的 Gradle 配置中,请单击此处