wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.6k stars 557 forks source link

RN 0.72 error #741

Open billnbell opened 1 year ago

billnbell commented 1 year ago

/Users/bill_1/theclub/TheClub/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java:29: error: PdfManager is not abstract and does not override abstract method showsVerticalScrollIndicator(PdfView,boolean) in RNPDFPdfViewManagerInterface public class PdfManager extends SimpleViewManager implements RNPDFPdfViewManagerInterface { ^ /Users/bill_1/theclub/TheClub/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java:97: error: method does not override or implement a method from a supertype @Override ^ /Users/bill_1/theclub/TheClub/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java:102: error: method does not override or implement a method from a supertype @Override ^ Note: /Users/bill_1/theclub/TheClub/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfView.java uses or overrides a deprecated API.

Getting this with yarn android.

lufercampos commented 1 year ago

I have updated from RN 0.71.10 to RN 0.72.0, now I am getting the same error:

...\node_modules\react-native-pdf\android\src\main\java\org\wonday\pdf\PdfManager.java:29: error: PdfManager is not abstract and does not override abstract method showsVerticalScrollIndicator(PdfView,boolean) in RNPDFPdfViewManagerInterface public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfViewManagerInterface<PdfView> { ^ ...\node_modules\react-native-pdf\android\src\main\java\org\wonday\pdf\PdfManager.java:97: error: method does not override or implement a method from a supertype @Override ^ ...\node_modules\react-native-pdf\android\src\main\java\org\wonday\pdf\PdfManager.java:102: error: method does not override or implement a method from a supertype @Override ^

billnbell commented 1 year ago

They deprecated

  // void showsHorizontalScrollIndicator(T view, boolean value);
  // void showsVerticalScrollIndicator(T view, boolean value);
billnbell commented 1 year ago

OK here is a patch patches/react-native-pdf+6.7.0.patch react-native-pdf+6.7.0.patch

thefranfran commented 1 year ago

@billnbell how to setup it? I followed the git instructions but eas build didn't work

zhuanghongji commented 1 year ago

react-native-pdf+6.7.0.patch

The patch above is purer as it only changes the deprecated function name without requiring the android-build-files patch.

The following text is the content:

diff --git a/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java b/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java
index 84338e5..783af9b 100644
--- a/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java
+++ b/node_modules/react-native-pdf/android/src/main/java/org/wonday/pdf/PdfManager.java
@@ -95,12 +95,12 @@ public class PdfManager extends SimpleViewManager<PdfView> implements RNPDFPdfVi
     }

     @Override
-    public void setShowsHorizontalScrollIndicator(PdfView view, boolean value) {
+    public void showsHorizontalScrollIndicator(PdfView view, boolean value) {
         // NOOP on Android
     }

     @Override
-    public void setShowsVerticalScrollIndicator(PdfView view, boolean value) {
+    public void showsVerticalScrollIndicator(PdfView view, boolean value) {
         // NOOP on Android
     }
Aaqib925 commented 1 year ago

@zhuanghongji Can you please guide on how to apply this patch ?

billnbell commented 1 year ago

Seriously?

yarn add patch-package

Save the file in patches directory.

Add into packages.json in scripts:

"postinstall": "npx patch-package"

Then run yarn install

billnbell commented 1 year ago

I'll create a fork/PR

zhuanghongji commented 1 year ago

@zhuanghongji Can you please guide on how to apply this patch ?

@Aaqib925 Just like @billnbell comment above, or you can check more detail in ds300/patch-package.

lufercampos commented 1 year ago

for those who want to create their own path:

open android studio go to the file with the error fix the errors (Android Studio will suggest the solution) yarn add patch-package yarn run patch-package -- react-native-pdf yarn install

billnbell commented 1 year ago

Patch react-native-pdf+6.7.1.patch for RN 0.72.1 tested for IOS

diff --git a/node_modules/react-native-pdf/react-native-pdf.podspec b/node_modules/react-native-pdf/react-native-pdf.podspec
index fb36140..f125f0d 100644
--- a/node_modules/react-native-pdf/react-native-pdf.podspec
+++ b/node_modules/react-native-pdf/react-native-pdf.podspec
@@ -28,6 +28,24 @@ Pod::Spec.new do |s|
     s.source_files    = 'ios/**/*.{h,m,mm,cpp}'
     s.requires_arc    = true

+    s.dependency "React-utils"
+    s.dependency "React-debug"
+    s.subspec "xxxdebug" do |ss|
+      ss.dependency "ReactCommon"
+      ss.dependency "React-debug"
+      ss.source_files         = "react/debug/**/*.{cpp,h}"
+      ss.header_dir           = "react/debug"
+      ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-debug/React_debug.framework/Headers\"" }
+    end
+
+    s.subspec "xxxutils" do |ss|
+      ss.dependency "ReactCommon"
+      ss.dependency "React-utils"
+      ss.source_files         = "react/utils/**/*.{cpp,h}"
+      ss.header_dir           = "react/utils"
+      ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-utils/React_utils.framework/Headers\"" }
+    end
+
     s.dependency "React"
     s.dependency "React-RCTFabric"
     s.dependency "React-Codegen"