react-native-clipboard / clipboard

React Native Clipboard API for both iOS and Android.
MIT License
669 stars 118 forks source link

fix: module spec mis-match on Android (new Architecture) #237

Closed alanleedev closed 2 months ago

alanleedev commented 2 months ago

Overview

I get the following build error on Android with new architecture enabled. Created a test app using the guide here: https://gist.github.com/cipolleschi/82b7a9561b8861330efabbd3eb08c6f5#file-test-your-library-against-react-native-0-74-0-rcs-md RN version: 0.74.0-rc.9

/src/ClipboardTest/node_modules/@react-native-clipboard/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:39: error: ClipboardModule is not abstract and does not override abstract method removeListeners(int) in NativeClipboardModuleSpec
public class ClipboardModule extends NativeClipboardModuleSpec {
       ^
/src/ClipboardTest/node_modules/@react-native-clipboard/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:240: error: method does not override or implement a method from a supertype
  @Override
  ^

This is due to mismatch with JS Spec in NativeClipboardModule.ts: removeListeners(count: Int32): void;

Where as NativeClipboardModuleSpec.java defines as public abstract void removeListeners(float count);

==> Update float to int so both legacy and new architecture is using the same type defined in the spec.

Test Plan

Created a test app using the guide here: https://gist.github.com/cipolleschi/82b7a9561b8861330efabbd3eb08c6f5#file-test-your-library-against-react-native-0-74-0-rcs-md

alanleedev commented 2 months ago

@Naturalclar Could you review this PR? It is needed to support new architecture. Java spec for legacy architecture does not match the auto generated spec on new architecture.