react-native-clipboard / clipboard

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

Not working in Android 10 #65

Open caifel opened 4 years ago

caifel commented 4 years ago

Environment

Platforms

Android

Versions

Description

Instead of the clipboard object null is returned.

Reproducible Demo

https://snack.expo.io/@aboutreact/clipboard-example?session_id=snack-session-45GVESXWi

caifel commented 4 years ago

Sorry for not adding extra details, but it is as simple as that

dkocich commented 4 years ago

I also could not make it run on Android 10 (32-bit emulator with Expo v38.0.8). There is an orange box saying null is not an object (evaluating NativeClipboard_1.default.setString)

I found a demo but it is not supported for Android 10 too (expo SDK newer than v32 when I tried to use it on Android 120 physical device). https://snack.expo.io/@aboutreact/clipboard-example?session_id=snack-session-45GVESXWi

firdaussoberi commented 4 years ago

I also had the same issue and it breaks my production app. What's weird is it works fine on one Android9 phone (Redmi Note7) and not the other running Android9 (Galaxt Note 8). Android10 straight out gives similar error. Using RN0.60.4. If anyone can advise it would be cool. Thanks

firdaussoberi commented 4 years ago

I also had the same issue and it breaks my production app. What's weird is it works fine on one Android9 phone (Redmi Note7) and not the other running Android9 (Galaxt Note 8). Android10 straight out gives similar error. Using RN0.60.4. If anyone can advise it would be cool. Thanks

Nvm. Found the issue, I've been using react-native-code-push package and just added the clipboard library today. Forgot that the codepush only involves js files so it's library linking/binary issue. For others, try to check linking first or make sure the clipboard library is in node_modules

guitorioadar commented 4 years ago

Same issue here...

IbrahimSalem0 commented 4 years ago

same Issue here but i face that 👍 object (evaluating NativeClipboard_1.default.getString)

alexttyip commented 4 years ago

Related to #53, use the deprecated Clipboard instead if you're using Expo.

IbrahimSalem0 commented 4 years ago

I solve it after I Add Clipboard from React Native Comunity

cmcaboy commented 4 years ago

I am not using expo and I am running into this issue.

cmcaboy commented 4 years ago

I was able to fix this by manually adding the Clipboard package to MainApplication.java. For whatever reason, the link command did not add it. I'm on 0.59.10.

import com.reactnativecommunity.clipboard.ClipboardPackage; // <- Add this line
// other import commands

public class MainApplication extends Application implements ReactApplication {
// other code

 @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          // Other packages...
          new ClipboardPackage() // <- Add this line
      );
    }
// ....More code
wangqiking commented 4 years ago

I have the same problem, but it can be solved by uninstalling the app and re installing it

android 8.0.0 RN 0.63.1 @react-native-community/clipboard 1.2.3

dustinyoste commented 3 years ago

Additionally to @cmcaboy You might need to include

    implementation project(':@react-native-clipboard_clipboard')

in android/app/build.gradle within dependencies {

and

include ':@react-native-clipboard_clipboard'
project(':@react-native-clipboard_clipboard').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-clipboard/clipboard/android')

in android/settings.gradle

miladezzat commented 2 years ago

The same issue