react-native-pdf-lib
react-native-pdf-lib copied to clipboard
Error installing the app with react-native-pdf-lib
Hi,
When I run react-native run-android :
> Task :app:checkDebugDuplicateClasses FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class com.tom_roush.fontbox.afm.AFMParser found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.afm.CharMetric found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.afm.Composite found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.afm.CompositePart found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.afm.FontMetrics found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.afm.KernPair found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.afm.Ligature found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.afm.TrackKern found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.cff.CFFCIDFont found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.cff.CFFCIDFont$1 found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
Duplicate class com.tom_roush.fontbox.cff.CFFCIDFont$PrivateType1CharStringReader found in modules jetified-pdfbox-android-1.8.10.3-runtime (com.tom-roush:pdfbox-android:1.8.10.3) and jetified-pdfbox-android-1.8.9.1-runtime (com.tom_roush:pdfbox-android:1.8.9.1)
... and more ...
Then I tried to add
android {
configurations {
all*.exclude module: 'android-pdf-viewer'
}
...
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
} }
But the following error now :
> Task :app:mergeDebugJavaResource FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> java.nio.file.FileSystemException: ...\android\app\build\intermediates\merged_java_res\debug\out.jar: The process cannot access the file because this file is in use by another process.
Versions
"react-native": "0.64.2"
"react-native-pdf-lib": "^1.0.0"
"react-native-html-to-pdf": "^0.11.0"
"react-native-print": "^0.9.0",
Thanks for your recommandations
I forgot to add https://github.com/TomRoush/PdfBox-Android.
Now I have this error :
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 17s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
...\android\app\src\main\java\com\dahyitad\MainApplication.java:7: error: package com.hopding.pdflib does not exist
import com.hopding.pdflib.PDFLibPackage;
This looks like your Android dev environment isn't set up correctly. Could you provide a reproduction?
I have a lot of dependencies but only yours is making problem :
"@react-native-community/async-storage": "^1.12.1",
"@react-native-community/cameraroll": "^4.1.2",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/bottom-tabs": "^5.11.2",
"@react-navigation/native": "^5.8.10",
"@react-navigation/stack": "^5.12.8",
"accordion-collapse-react-native": "^1.0.1",
"formik": "^2.2.9",
"immutable": "^4.0.0-rc.14",
"moment": "^2.29.1",
"react": "17.0.1",
"react-addons-update": "^15.6.3",
"react-native": "0.64.2",
"react-native-camera": "^4.2.1",
"react-native-camera-hooks": "^0.5.2",
"react-native-collapsible": "^1.6.0",
"react-native-elements": "^3.4.2",
"react-native-fs": "^2.18.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-html-to-pdf": "^0.11.0",
"react-native-image-picker": "^4.1.2",
"react-native-iphone-x-helper": "^1.3.1",
"react-native-maps": "^0.29.0",
"react-native-maps-directions": "^1.8.0",
"react-native-modal-datetime-picker": "^11.0.0",
"react-native-paper": "^4.9.2",
"react-native-pdf-lib": "^1.0.0",
"react-native-print": "^0.9.0",
"react-native-reanimated": "^2.2.0",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.15.0",
"react-native-signature-canvas": "^4.3.0",
"react-native-svg": "^9.12.0",
"react-native-vector-icons": "^8.1.0",
"react-native-webview": "^11.14.0",
"react-redux": "^7.2.4",
"react-to-print": "^2.14.0",
"react-uuid": "^1.0.2",
"redux": "^4.1.0",
"redux-persist": "^6.0.0",
"yup": "^0.32.9"
In my first comment, I use automatic installation like your purpose and I had this type of error.
It should work with automatic installation??
Is it necessary to insall PdfBox-Android?
Ok I give up. Your library is not up-to-date... I lost hours and hours with that..
for example : com.tom_roush:pdfbox-android:1.8.9.1
new version : com.tom-roush:pdfbox-android:2.0.8.0
I just need to create many differents pages with header/footer/pagination on a PDF. Why is that so complicated??
Pull requests are welcome to bring things more up to date.
Hi! The library helps me a lot, thank you.
I had the same issue and one patch figure out it:
node_modules/react-native-pdf-lib/android/build.gradle
dependencies {
- implementation 'com.tom_roush:pdfbox-android:1.8.9.1'
+ implementation 'com.tom-roush:pdfbox-android:1.8.10.3'
implementation 'com.facebook.react:react-native:+'
}
@jalinegm thanks!! its works!!
