react-native-builder-bob icon indicating copy to clipboard operation
react-native-builder-bob copied to clipboard

Error on bob aar build

Open LerDelijan opened this issue 6 years ago • 7 comments

Question

Hello, My goal is to build an aar using bob. After I've executed create script: npx @react-native-community/bob create react-native-awesome-module I have added aar to targets in package.json:

"@react-native-community/bob": {
    "source": "src",
    "output": "lib",
    "targets": [
      ["aar", { "reverseJetify": true }],
      "commonjs",
      "module",
      "typescript"
    ]
  }

The error I get is as follows:

D:\react-native-awesome-module>bob build
ℹ Building target aar
ℹ Cleaning up previous build at lib\aar
ℹ Assembling Android project in android with gradle
bob.js build

build files for publishing

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Error: The gradlew script doesn't seem to present in android. Make sure you have added it by running gradle wrapper in that directory.
    at androidAssemble (D:\react-native-awesome-module\node_modules\@react-native-community\bob\lib\utils\androidAssemble.js:35:11)
    at async build (D:\react-native-awesome-module\node_modules\@react-native-community\bob\lib\targets\aar.js:44:3)
    at async Object.handler (D:\react-native-awesome-module\node_modules\@react-native-community\bob\lib\cli.js:320:9)

Both gradlew and gradlew.bat files do present in android directory. image

Should I add some extra configuration to build an aar or I have missed something in docs?

Thanks in advance!

LerDelijan avatar Aug 18 '20 08:08 LerDelijan

cc @matt-oakes any ideas?

krizzu avatar Sep 30 '20 16:09 krizzu

I think this is the issue here. On windows, gradleWrapper gets resolved to ./gradlew./gradlew.bat which doesn't work. I changed that line to the following and it ran without problems:

  const gradleWrapper = ((0, _os.platform)() === 'win32' ? 'gradlew.bat' : './gradlew');

stacygrace avatar Feb 24 '21 04:02 stacygrace

@chadmorrow Thank you for finding the solution! Perhaps you would like to make a PR solving this issue with the fix you found?

BartoszKlonowski avatar May 31 '21 19:05 BartoszKlonowski

Sure! I can work on that later today

stacygrace avatar May 31 '21 20:05 stacygrace

@chadmorrow Thank you! I assigned you to this item just in case. Take your time and thank you for contributing!

BartoszKlonowski avatar May 31 '21 20:05 BartoszKlonowski

I ran into the same problem. I'll try it your way. @chadmorrow

AsteriskZuo avatar Apr 17 '22 03:04 AsteriskZuo

@chadmorrow how to implement const gradleWrapper = ((0, _os.platform)() === 'win32' ? 'gradlew.bat' : './gradlew'); this file or other reference

himanshurtanikatech avatar Jul 04 '23 14:07 himanshurtanikatech