简体   繁体   中英

Error when generate Gradle Wrapper files

I have a react native project in ubuntu, and I want to generate Gradle Wrapper files so I install gradle and in android/app I have run this command

gradle wrapper --gradle-version 3.4.1

But when I run this command, I got this error

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

My problem happened because I called SigningConfig without defined it

So I solved this problem by defining SigningConfig in /var/MY_PROJECT/android/app/build.gradle

...
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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM