react-native-sound: cannot compile android with RN 0.53
I have:
- react-native-cli: 2.0.1
- react-native: 0.53.0
And i get:
node_modules/react-native-sound/android/src/main/java/com/zmxv/RNSound/RNSoundModule.java:43: error: cannot find symbol
final ReactContext reactContext = this.context;
^
symbol: class ReactContext
location: class RNSoundModule
any idea? 0.53 is not supported?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 21
@r3vox @sergey-tyan actually you just need to do
yarn add react-native-sound@0.10.2
. No need to remove the existing version before doing so, and also no need to unlink then re-link the module.Take note that for v0.10.4 and older,
Sound.setCategory
doesn’t work on Android, so you can’t play sounds when the device is in silent mode.v0.10.5 introduced the feature on Android, but then screwed up the sound keys, causing https://github.com/zmxv/react-native-sound/issues/362.
It’s already fixed on master branch, but then now master branch can’t even compile, at least on Android. This isn’t an issue with the RN version, as what @badpenguin originally thought. And there are multiple open issues (this, https://github.com/zmxv/react-native-sound/issues/380, https://github.com/zmxv/react-native-sound/issues/382) that all stem from the same problem. Do contributors even test if the code can compile before merging them into master branch? It’s as if people are expecting Java to perform implicit typecasting between Double and Integer types. And then there are also missing imports (e.g.
ReactContext
), as well as missing function definitions (e.g.sendEvent
).I’d like to contribute and help fix this, but then I’m not even sure what some of the contributors were trying to do with their commits. What kind of commit message (https://github.com/zmxv/react-native-sound/commit/fa95e5935ca13511d0199f8ac699e114c89d58eb) is “Need test”!? In fact, this commit, along with https://github.com/zmxv/react-native-sound/commit/ce1f59e6fa05d3582f7ecd895c5e06c5ba3db8a2 (changing Integer to Double), are the ones responsible for causing the Java module to fail to compile. The code posted by @Kroniac effectively undoes their changes. But I don’t think that’s a proper long term solution. Just my 2 cents.
I downgraded to react-native-sound^0.10.2 and it is working now
@esmatptr worked for me too @r3vox remove current version and install 0.10.2
in your project folder go to node_modules\react-native-sound\android\src\main\java\com\zmxv\RNSound\RNSoundModule.java and replace all the file contents with following code:
Neither rolling back to RN 0.52.2 nor installing react-native-sound from master resolved this issue. ```` “react-native-sound”: “https://github.com/zmxv/react-native-sound.git”,