Repository navigation
Description
Environment
react-native info unfortunately does not produce fully valid results in my case. The valid part is
here
System:
OS: macOS 10.15.3
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 1.23 GB / 16.00 GB
Shell: 5.0.11 - /usr/local/bin/bash
Binaries:
Node: 12.14.1 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.8.4 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
Android NDK: 17.2.4988734
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6308749
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
Description
In https://github.com/react-native-community/datetimepicker there is an example project in the example folder. I'm using the kind of setup that it common in many of the community repositories where the example app links to the native and js code which is in the parent folder.
In the master branch with RN 0.60.4, I'm able to run react-native run-android --root example/ and get the build running.
In the @vonovak/enable-detox branch which uses RN 0.62.1 and @react-native-community/cli@^4.5.1 , if I run the same command, I get
Error: ENOENT: no such file or directory, open '/src/main/AndroidManifest.xml'
at Object.openSync (fs.js:440:3)
at Object.readFileSync (fs.js:342:35)
at buildAndRun (/Users/vojta/dev/_own/datetimepicker/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:162:41)
at /Users/vojta/dev/_own/datetimepicker/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:146:12
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async Command.handleAction (/Users/vojta/dev/_own/datetimepicker/node_modules/@react-native-community/cli/build/index.js:186:9)
(yes, the file is not there). It would be nice to have some more docs about how the detection works https://github.com/react-native-community/cli/blob/master/docs/commands.md#--root-string
Reproducible Demo
https://github.com/react-native-community/datetimepicker @vonovak/enable-detox branch
Activity
thymikee commentedon Apr 6, 2020
You can specify where the source of your Android project is using
project.android.sourceDir: https://github.com/react-native-community/cli/blob/5e5d50dcbe689db294b620b72a2f66eed5bf3bba/docs/projects.md#project-1, similar to what we allow to modify in dependencies: https://github.com/react-native-community/cli/blob/79498d598e00e481e6058a2892eaa71870215922/docs/dependencies.md#platformsandroidsourcedirthymikee commentedon Apr 6, 2020
I agree we need better docs around it
troZee commentedon Apr 9, 2020
I encountered the same issue and I resolved it as follow:
I created
react-native.config.jsfile in root dir (at the same level as package.json file ), which contains below code:Where android project is located inside
'./example/androidYou can also check all dirs using
react-native configcommand.vonovak commentedon Apr 20, 2020
okay, thank you for the comments; I circled back to this but wasn't able to make it work with the sample provided. I'm still getting an error, albeit slightly different. I'm on 4.7.0.
the error message (more or less the same as above) is
react-native.config.js:
the place where the error comes from:
cli/packages/platform-android/src/commands/runAndroid/index.ts
Line 137 in bfc4ec2
I placed
console.log(process.cwd(), args, androidProject)in there and the output issee
process.chdir(path.join(args.root, 'android'));- is that correct?If I change that to
process.chdir(androidProject.sourceDir);the build runs fine for me.output of
react-native configlooks fine to me.I'm currently having this only locally but I can push it if you want!
Thank you!
thymikee commentedon Apr 20, 2020
Thanks for the thorough investigation!
This is correct. Previous code is a left over from previous implementation. Please send a PR if you can 🙏
thymikee commentedon Apr 20, 2020
Closed via #1122