react-native-clipboard / clipboard

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

Android: After upgrading to React Native version 0.73, build failed #214

Closed bogdan-boksan-ananas closed 10 months ago

bogdan-boksan-ananas commented 10 months ago

Environment

  OS: macOS 14.1.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 168.47 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 9.5.1
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.05.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/b/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 28.0.3
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-33 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.2 AI-222.4459.24.2221.9971841
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.8.1
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/b/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: ^18.2.0
  react-native:
    installed: 0.73.0
    wanted: ^0.73
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Platforms

Android

Versions

Description

After upgrading RN to 0.73, when running app on Android, I get this error:

import com.facebook.react.bridge.ContextBaseJavaModule;
                                ^
  symbol:   class ContextBaseJavaModule
  location: package com.facebook.react.bridge
/Users/b/Work/Projects/app/node_modules/@react-native-community/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:23: error: cannot find symbol
public class ClipboardModule extends ContextBaseJavaModule {
                                     ^
  symbol: class ContextBaseJavaModule
/Users/b/Work/Projects/app/node_modules/@react-native-community/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardPackage.java:23: error: incompatible types: ClipboardModule cannot be converted to NativeModule
    modules.add(new ClipboardModule(reactContext));
                ^
/Users/b/Work/Projects/app/node_modules/@react-native-community/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:31: error: method does not override or implement a method from a supertype
  @Override
  ^
/Users/b/Work/Projects/app/node_modules/@react-native-community/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:37: error: cannot find symbol
    return (ClipboardManager) getContext().getSystemService(getContext().CLIPBOARD_SERVICE);
                                                            ^
  symbol:   method getContext()
  location: class ClipboardModule
/Users/b/Work/Projects/app/node_modules/@react-native-community/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:37: error: cannot find symbol
    return (ClipboardManager) getContext().getSystemService(getContext().CLIPBOARD_SERVICE);
                              ^
  symbol:   method getContext()
  location: class ClipboardModule
Note: /Users/b/Work/Projects/app/node_modules/@react-native-community/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
6 errors
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/b/Work/Projects/app/node_modules/@react-native-async-storage/async-storage/android/src/javaPackage/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

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.

BUILD FAILED in 1m 31s
dmregister commented 9 months ago

@bogdan-boksan-ananas what was the solution?

bogdan-boksan-ananas commented 9 months ago

@dmregister I didn't realise the project had this version of the library: "@react-native-community/clipboard": "^1.5.1"

and it should be this: "@react-native-clipboard/clipboard": "^1.12.1"

hamza157kashif commented 9 months ago

still getting the error due to this

there is no version 1.12.1. @bogdan-boksan-ananas

milankakadiya2001 commented 9 months ago

@bogdan-boksan-ananas @hamza157kashif try with a different version but not working @react-native-clipboard/clipboard

Does anyone know the solution?

issue++

matthewadel commented 9 months ago

just relace clipboard line in package.json from "@react-native-community/clipboard":"^x.x.x" with "@react-native-community/clipboard": "https://github.com/react-native-clipboard/clipboard.git",

then yarn, rebuild your project

sushant-startupwind commented 8 months ago

@matthewadel thanks for solution...

johhansantana commented 7 months ago

https://github.com/react-native-clipboard/clipboard.git

@matthewadel why doesn't install the latest version when doing yarn install without specifying the git repo?

1mike12 commented 2 months ago

@johhansantana because the version on npm is behind the master branch and they havent made a release since april. It's a terrible solution since you are not really pointing at a specific version of the library, but a branch that can change at any time