react-native-push-notification: Android build error with react-native@0.30.0

I get this error when building with react-native@0.30.0:

node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java:64: error: method does not override or implement a method from a supertype
    @Override
    ^
1 error

Quick link to line

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 10
  • Comments: 42 (9 by maintainers)

Most upvoted comments

Rolling back to 2.0.1 fixed it for now, while still being on rn 0.30.0 "react-native-push-notification": "2.0.1"

I’m inclined to agree. If people want new features and fixes they need to upgrade their version or RN. Otherwise they’re free to fork and maintain their own version.

Just published 2.1.0

Everything is updated and this is the error I get trying to compile it with react-native@0.31:

./node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java:64: error: method does not override or implement a method from a supertype
    @Override
    ^
1 error
:react-native-push-notification:compileReleaseJavaWithJavac FAILED

@luisfuertes for RN v0.29.1 try using 2.0.1 npm install react-native-push-notification@2.0.1

I found out that my configuration in ./android/build.gradle was not correctly set. It needs to be set to: url "$rootDir/../node_modules/react-native/android" instead of url "$projectDir/../../node_modules/react-native/android"

Did you guys all upgrade from a previous version of RN? For me the error was fixed after I ran react-native upgrade, and made sure all files in android/ were up-to-date.

That’s good that it works on RN0.33 because I’ve been testing on rn0.32 (haddn’t tried 33 yet). Hold off on the release though, it was quite a big change. Wouldn’t mind getting a few people to try it first.

To fix the incompatibility problem I took out the @Override annotations, and left both implementations of the problematic method in. So I think thats why it works with RN33 and earlier now. It was a guess though, apologies if its not correct.

The annotations are only a compile-time tool and have no effect at runtime. In a sense they’re totally optional. IMO it’s always a good idea to use them, commenting them out is a hack, but until its decided that this project only supports the latests RN (maybe?) then I guess we can leave both implementations of the method in.

I’d suggest that supporting more than 1 version of RN is going to be a nightmare. Perhaps each time RN becomes incompatible we simply make a branch for the old one, and keep master compatible with the latest RN? Then just link to the branch on the README file for this people who want the old version.

Yes it would seem so 😃 I think I will switch to installing from github as well for now.

Had this problem also, had to

npm cache clear
rm -Rf node_modules
npm install

After than 2.0.2 + rn 0.30.0 works properly.