React-native-onesignal: cannot find symbol : OneSignal.setExternalUserId(externalId);

Created on 2 Jan 2019  路  18Comments  路  Source: OneSignal/react-native-onesignal

Description:
After upgrading react-native-onesignal to 3.2.12. I am facing build error issue in Android.

Build Error:

cannot find symbol
OneSignal.setExternalUserId(externalId);
^
symbol: method setExternalUserId(String)
location: class OneSignal

error: cannot find symbol
OneSignal.removeExternalUserId();
^
symbol: method removeExternalUserId()
location: class OneSignal

(your description here)

Environment

react-native-onesignal : 3.2.12
React-native : 0.57.7

Steps to Reproduce Issue:

  1. Did all steps to include plugin in app.(https://documentation.onesignal.com/docs/react-native-sdk-setup)
  2. run react-native run-android
    3.

Anything else:

(crash stacktraces, as well as any other information here)

Most helpful comment

Removing cache from ~/.gradle/caches works for me somehow

All 18 comments

I am facing exact the same problem :(
RN 0.57.8
RNOneSignal 3.2.12

@JsonAveza I am not able to reproduce this issue with our latest SDK. I've even inspected our npm package manually, and those methods are definitely defined in Android.

Can you please run npm cache clean --force and try deleting your node_modules folder, then try running an npm install again. Make sure you are using 3.2.12.

If you are still having this problem after that, please try downloading our example project (in the /examples folder of this repo) and please try reproducing there. If you can, please zip it up and post me a link.

Same here
RN 0.57.8
RNOneSignal 3.2.12

It does work with example project as gradle version there is 3.0.1 (android/build.gradle). I had 3.1.0 there and then it failed with above mentioned error message.

@stockrel @martinosmartinos can either of you download the example project from our /examples/RNOneSignal folder and see if you can reproduce it there? If so, please go ahead and zip it up and send it to me as I cannot reproduce the issue and neither can several others in our office.

Same issue, Tried 3.0.1 but no luck

@ewindso try removing RNOnesignal package from npm folder, clean npm cache (npm cache clean --force), change android/build.gradle to 3.0.1, run install and then rebuild.

@Nightsd01 I will try to reproduce named issue with example project. Will keep you posted.

I had the same issue with
RN 0.57.8
RNOneSignal 3.2.12
gradle 3.1.0

when i check ./gradlew app:dependencies
onesignal project resolve to com.onesignal:OneSignal:3.10.1 where as the porject need com.onesignal:OneSignal:3.10.5.

after cleaning all gradle cache, it works.
u can first check if dependency resolve to an older version instead of 3.10.5. If it does, refresh dependency for gradle.
If it still doesnt work, remove the whole gradle cache and redownload everything. This will take a long time though. Try refresh dependency first

Not sure why it will not refresh dependency itself though.

@JCheungX thank you! that worked

It seems like this is just an issue with cached dependencies and isn't an actual issue with our SDK. Please let me know if you have any further questions/problems regarding this feature and I'll reopen the issue.

@JCheungX which ./gradlew file did you change? I have cleaned the gradle cache and it still seems to not be working. Thanks!

@JCheungX which ./gradlew file to be exact? still not working after npm cache clean --force and delete node module.

I tried cleaning gradle cache as described here but it didn't work.

In my case node_modules\react-native-onesignal\android\build.gradle wasn't updated somehow to project com.onesignal:OneSignal:3.10.5

For me updating line 25 at node_modules\react-native-onesignal\android\build.gradle
from 'com.onesignal:OneSignal:3.10.1'
to 'com.onesignal:OneSignal:3.10.5'
solved the problem

Removing cache from ~/.gradle/caches works for me somehow

For me this issue solved by going to
Preferences --> Experimental --> Unchecking "Only sync with active variant".

It's not working for me either, I tried everything adviced in the ticket.
I ended up downgrading to 3.2.11 to make it working

Lib Version
RN: "0.57.0"
OneSignal: "3.1.4" -> "3.2.12"
Gradle: "3.3.0"

Steps Followed

  1. rm -rf ~/.gradle/caches
  2. rm -rf node_modules && npm i
  3. react-native link react-native-onesignal
  4. Restarted packager with react-native start --reset-cache
  5. react-native run-android (on device)

Error

> Task :react-native-onesignal:compileDebugJavaWithJavac FAILED
/Applications/MAMP/htdocs/numu/app/node_modules/react-native-onesignal/android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java:392: error: cannot find symbol
      OneSignal.setExternalUserId(externalId);
               ^
  symbol:   method setExternalUserId(String)
  location: class OneSignal
/Applications/MAMP/htdocs/numu/app/node_modules/react-native-onesignal/android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java:397: error: cannot find symbol
      OneSignal.removeExternalUserId();
               ^
  symbol:   method removeExternalUserId()
  location: class OneSignal
Note: /Applications/MAMP/htdocs/numu/app/node_modules/react-native-onesignal/android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
Was this page helpful?
0 / 5 - 0 ratings