revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.33k stars 317 forks source link

NfcManager.java Build Error with setNdefPushMessage #657

Closed adeelcheeema closed 12 months ago

adeelcheeema commented 1 year ago

NfcManager.java -> setNdefPushMessage -> nfcAdapter.setNdefPushMessage(msgToPush, currentActivity);

Issue Description:

When trying to build the Android project, I encountered an issue related to NfcManager.java and the setNdefPushMessage function. Specifically, the build fails if I comment out the line nfcAdapter.setNdefPushMessage(msgToPush, currentActivity);. However, the build succeeds when this line is included.

Expected Behavior: The build should complete successfully even when the line nfcAdapter.setNdefPushMessage(msgToPush, currentActivity); is commented out.

Actual Behavior: The build fails when the line nfcAdapter.setNdefPushMessage(msgToPush, currentActivity); is commented out.

NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(context); nfcAdapter.setNdefPushMessage(msgToPush, currentActivity); callback.invoke();

Screenshot 2023-08-15 at 10 20 26 AM

This function has been removed in the Nfc Adapter Documentation. You can find more information about this change at the following link:

Changes in android.nfc.NfcAdapter

Screenshot 2023-08-15 at 11 15 33 AM
nicolasburtey commented 12 months ago

I think I'm having the same issue on my app when upgrading gradle

the log I have from the build:

> Task :react-native-nfc-manager:compileDebugJavaWithJavac FAILED
/Users/n/Code/galoy-mobile/node_modules/react-native-nfc-manager/android/src/main/java/community/revteltech/nfc/NfcManager.java:967: error: cannot find symbol
                    nfcAdapter.setNdefPushMessage(msgToPush, currentActivity);
                              ^
  symbol:   method setNdefPushMessage(NdefMessage,Activity)
  location: variable nfcAdapter of type NfcAdapter
Note: /Users/n/Code/galoy-mobile/node_modules/react-native-nfc-manager/android/src/main/java/community/revteltech/nfc/NfcManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
kirandchavan commented 12 months ago

yes, this error is coming with react native version "react-native": "0.72.4", "react-native-nfc-manager": "^3.14.6",

whitedogg13 commented 12 months ago

Hi @nicolasburtey @adeelcheeema @kirandchavan you're right! I have removed the deprecated api and released v3.14.7, please give it a try & thanks for the information!