Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native-clipboard_clipboard not working RN 0.75.3 in new architecture #259

Closed
RameshKrish29 opened this issue Sep 24, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@RameshKrish29
Copy link

Environment

System:
OS: Windows 11 10.0.22631
CPU: "(4) x64 AMD Ryzen 3 3250U with Radeon Graphics "
Memory: 606.93 MB / 5.89 GB
Binaries:
Node:
version: 21.6.2
path: C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm:
version: 10.2.4
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "31"
- "33"
- "34"
Build Tools:
- 30.0.3
- 33.0.0
- 34.0.0
System Images:
- android-34 | Google APIs Intel x86_64 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-231.9392.1.2311.11330709
Visual Studio: Not Found
Languages:
Java: 18.0.2.1
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.75.3
wanted: 0.75.3
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

Platforms

Android

Description

Task :react-native-clipboard_clipboard:processDebugManifest
package="com.reactnativecommunity.clipboard" found in source AndroidManifest.xml: D:\Projects\SampleProjects\RN0_75_3\node_modules@react-native-clipboard\clipboard\android\src\main\AndroidManifest.xml.
Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported, and the value is ignored.
Recommendation: remove package="com.reactnativecommunity.clipboard" from the source AndroidManifest.xml: D:\Projects\SampleProjects\RN0_75_3\node_modules@react-native-clipboard\clipboard\android\src\main\AndroidManifest.xml.

Task :react-native-clipboard_clipboard:compileDebugJavaWithJavac

Task :react-native-clipboard_clipboard:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
45 actionable tasks: 35 executed, 10 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

D:\Projects\SampleProjects\RN0_75_3\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(double) in NativeClipboardModuleSpec
public class ClipboardModule extends NativeClipboardModuleSpec {
^
D:\Projects\SampleProjects\RN0_75_3\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
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Projects\SampleProjects\RN0_75_3\node_modules@react-native-clipboard\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardPackage.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-clipboard_clipboard:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --info option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 27s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

@RameshKrish29 RameshKrish29 added the bug Something isn't working label Sep 24, 2024
@jorgegvallejo
Copy link

jorgegvallejo commented Sep 24, 2024

ClipboardModule is not abstract and does not override abstract method removeListeners(double) in NativeClipboardModuleSpec
public class ClipboardModule extends NativeClipboardModuleSpec {
^
D:\Projects\SampleProjects\RN0_75_3\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

This is the same error I'm getting on RN 0.75.3

@jorgegvallejo
Copy link

#238 (comment)

This seems to fix it

@RameshKrish29
Copy link
Author

#238 (comment)

This seems to fix it

Thanks @jorgegvallejo Its working for me, can we resolve it without patch. Is there any other fixes.

@adrielschmitz
Copy link

Same here. Any prevision to fix by patch?

@tommmoe
Copy link

tommmoe commented Oct 10, 2024

Looks like it's fixed now by the latest release? no issues migrating for me anymore

@michailbrynard
Copy link

Looks like it's fixed now by the latest release? no issues migrating for me anymore

Yes, it does look like it is fixed. I can confirm I am no longer seeing the issue on Android builds with version 1.14.2.

@dontuse
Copy link

dontuse commented Oct 17, 2024

0.75.4
@react-native-clipboard/clipboard@npm:1.14.2

emoveListeners(double) in NativeClipboardModuleSpec public class ClipboardModule extends NativeClipboardModuleSpec { ^ /Users/andreybayandin/work/mdp2/RN75/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 ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /Users/andreybayandin/work/mdp2/RN75/node_modules/@react-native-clipboard/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardPackage.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 2 errors

@Jeadonara
Copy link

The issue persists

@jagtarsinghwork
Copy link

jagtarsinghwork commented Oct 20, 2024

if you this type of error the update CLIBOARMODULE class

Task :react-native-community_clipboard:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
325 actionable tasks: 5 executed, 320 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

/Users/techveck/JAGTAR/software/knp/AJA/node_modules/@react-native-community/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:26: error: incompatible types: Context cannot be converted to ReactApplicationContext
super(context);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-community_clipboard:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --info option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 5s
info Run CLI with --verbose flag fo

WITH THIS WHOLE code and save

and run npm run android again


package com.reactnativecommunity.clipboard;

import android.content.ClipboardManager;
import android.content.ClipData;
import android.content.Context;

import com.facebook.react.bridge.ReactApplicationContext;  // Use ReactApplicationContext instead of Context
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Promise;
import com.facebook.react.module.annotations.ReactModule;

/**
 * A module that allows JS to get/set clipboard contents.
 */
@ReactModule(name = ClipboardModule.NAME)
public class ClipboardModule extends ReactContextBaseJavaModule {

	// Change the constructor to use ReactApplicationContext instead of Context
	public ClipboardModule(ReactApplicationContext reactContext) {
		super(reactContext);
	}

	public static final String NAME = "RNCClipboard";

	@Override
	public String getName() {
		return ClipboardModule.NAME;
	}

	private ClipboardManager getClipboardService() {
		// Use getReactApplicationContext() instead of getContext()
		return (ClipboardManager) getReactApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE);
	}

	@ReactMethod
	public void getString(Promise promise) {
		try {
			ClipboardManager clipboard = getClipboardService();
			ClipData clipData = clipboard.getPrimaryClip();
			if (clipData != null && clipData.getItemCount() >= 1) {
				ClipData.Item firstItem = clipboard.getPrimaryClip().getItemAt(0);
				promise.resolve("" + firstItem.getText());
			} else {
				promise.resolve("");
			}
		} catch (Exception e) {
			promise.reject(e);
		}
	}

	@ReactMethod
	public void setString(String text) {
		ClipData clipdata = ClipData.newPlainText(null, text);
		ClipboardManager clipboard = getClipboardService();
		clipboard.setPrimaryClip(clipdata);
	}

	@ReactMethod
	public void hasString(Promise promise) {
		try {
			ClipboardManager clipboard = getClipboardService();
			ClipData clipData = clipboard.getPrimaryClip();
			promise.resolve(clipData != null && clipData.getItemCount() >= 1);
		} catch (Exception e) {
			promise.reject(e);
		}
	}
}


@RameshKrish29
Copy link
Author

Yes, still Its exist

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-clipboard_clipboard:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --info option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 8m 3s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDevelopmentDebug -PreactNativeDevServerPort=8081
No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.
No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.
android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:1456:18: warning: the variable "DebuggerInternal" was not declared in function "__shouldPauseOnThrow" typeof DebuggerInternal !== 'undefined' && ^~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:6536:7: warning: the variable "setTimeout" was not declared in function "logCapturedError" setTimeout(function () { ^~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:4770:31: warning: the variable "nativeFabricUIManager" was not declared in anonymous function " 141#" var _nativeFabricUIManage = nativeFabricUIManager, ^~~~~~~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:4798:21: warning: the variable "clearTimeout" was not declared in anonymous function " 141#" cancelTimeout = clearTimeout; ^~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:4811:51: warning: the variable "RN$enableMicrotasksInReact" was not declared in anonymous function " 141#" ... "undefined" !== typeof RN$enableMicrotasksInReact && !!RN$enableMicrotask... ^~~~~~~~~~~~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:4812:47: warning: the variable "queueMicrotask" was not declared in anonymous function " 141#" ...otask = "function" === typeof queueMicrotask ? queueMicrotask : scheduleTi... ^~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:9233:30: warning: the variable "REACT_DEVTOOLS_GLOBAL_HOOK" was not declared in anonymous function " 141#" if ("undefined" !== typeof REACT_DEVTOOLS_GLOBAL_HOOK) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:11779:5: warning: the variable "setImmediate" was not declared in function "handleResolved" setImmediate(function () { ^~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16360:12: warning: the variable "fetch" was not declared in anonymous function " 393#" fetch: fetch, ^~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16361:14: warning: the variable "Headers" was not declared in anonymous function " 393#" Headers: Headers, ^~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16362:14: warning: the variable "Request" was not declared in anonymous function " 393#" Request: Request, ^~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16363:15: warning: the variable "Response" was not declared in anonymous function " 393#" Response: Response ^~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16520:24: warning: the variable "FileReader" was not declared in function "readBlobAsArrayBuffer" var reader = new FileReader(); ^~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16571:36: warning: the variable "Blob" was not declared in anonymous function " 404#" } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { ^~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16573:40: warning: the variable "FormData" was not declared in anonymous function " 404#" } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { ^~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16575:44: warning: the variable "URLSearchParams" was not declared in anonymous function " 404#" ...e if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body... ^~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16694:26: warning: the variable "AbortController" was not declared in anonymous function " 410#" var ctrl = new AbortController(); ^~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16828:23: warning: the variable "XMLHttpRequest" was not declared in anonymous function " 414#" var xhr = new XMLHttpRequest(); ^~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:16373:71: warning: the variable "self" was not declared in anonymous function " 396#" ...undefined' && globalThis || typeof self !== 'undefined' && self || ^~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:22004:30: warning: the variable "MessageChannel" was not declared in function "enqueueTaskImpl" if (typeof MessageChannel === 'undefined') { ^~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:30255:26: warning: the variable "navigator" was not declared in anonymous function " 729#" "undefined" !== typeof navigator && undefined !== navigator.scheduling && u... ^~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:30380:34: warning: the variable "nativeRuntimeScheduler" was not declared in anonymous function " 729#" ... = "undefined" !== typeof nativeRuntimeScheduler ? nativeRuntimeScheduler.... ^~~~~~~~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:39861:34: warning: the variable "requestAnimationFrame" was not declared in function "start 9#" ... this._animationFrame = requestAnimationFrame(this.onUpdate.bind(this)); ^~~~~~~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:77541:20: warning: the variable "WeakRef" was not declared in anonymous function " 2056#" var Ref = typeof WeakRef !== "undefined" ? WeakRef : StrongRef; ^~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:118275:11: warning: the variable "_WORKLET" was not declared in function "assertEasingIsWorklet" if (_WORKLET) { ^~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:119730:114: warning: the variable "location" was not declared in function "registerSensor" ...E(_dependencyMap[4]).isWeb)() && location.protocol !== 'https:' ? ' Make s... ^~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:120187:26: warning: Direct call to eval(), but lexical scope is not supported. workletFun = eval('(' + initData.code + '\n)'); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:120210:112: warning: the variable "_toString" was not declared in function "valueUnpacker" ...recognized by value unpacker: "${toString(objectToUnpack)}".`); ^~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:134971:27: warning: the variable "HTMLElement" was not declared in function "findDescendantWithExitingAnimation" if (!(node instanceof HTMLElement)) { ^~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:134998:24: warning: the variable "MutationObserver" was not declared in function "addHTMLMutationObserver" var observer = new MutationObserver(function (mutationsList) { ^~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:137193:41: warning: the variable "getComputedStyle" was not declared in function "fixElementPosition" ...entBorderTopValue = parseInt(getComputedStyle(parent).borderTopWidth); ^~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:137529:26: warning: the variable "structuredClone" was not declared in function "createAnimationWithInitialValues" var animationStyle = structuredClone($$_REQUIRE(_dependencyMap[6]).Anima... ^~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:141380:26: warning: the variable "_getAnimationTimestamp" was not declared in function "computeEasingProgress" var elapsedTime = (_getAnimationTimestamp() - startingTimestamp) / 1000; ^~~~~~~~~~~~~~~~~~~~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:141750:5: warning: the variable "jest" was not declared in function "beforeTest" jest.useFakeTimers(); ^~~~ android\app\build\generated\assets\createBundleDevelopmentDebugJsAndAssets\index.android.bundle:274566:113: warning: the variable "Intl" was not declared in function "PluralResolver" ...ons.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRul... ^~~~ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

@claudiozam
Copy link

Same issue in RN 0.76.0 new architecture

@irekrog
Copy link

irekrog commented Oct 24, 2024

this PR fixes it #251

@abrah4mr
Copy link

Is there anyone maintaining this library?

We been having this issue since july or before, and there's no fix available, also there are PRs from July fixing it.

CC: @Naturalclar @Saadnajmi

@Naturalclar
Copy link
Member

thanks for the ping! released 1.14.3 that will fix the issue 👍

@abrah4mr
Copy link

Thank you so much @Naturalclar!

@root123-bot
Copy link

The issue persist in react native 0.76.1 new architecture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests