rumax / react-native-PDFView

📚 PDF viewer for React Native
MIT License
300 stars 92 forks source link

Android build failing to get POM file as it is under basic authentication (getting 401) #245

Open bunnings-kamrul opened 1 year ago

bunnings-kamrul commented 1 year ago

Describe the bug Android build failing to get POM file as it is under basic authentication (getting 401)

To Reproduce React Native build started failing all on a sudden with following error Could not GET 'https://www.jitpack.io/com/github/barteksc/android-pdf-viewer/2.8.2/android-pdf-viewer-2.8.2.pom'. Received status code 401 from server: Unauthorized

Expected behavior The build process should be able to download POM file without any issue

Screenshots image

Additional context The build process was running from AppCenter agent, with following configuration

Agent name: 'Hosted Agent' Agent machine name: 'Mac-1687481783762' Current agent version: '3.220.5' macOS 11.7.7 20G1345 Node version: v16.20.1 npm version: 8.19.4 react-native-view-pdf@0.10.2

jmorrn commented 1 year ago

I've been receiving the same error in the recent hours.

Are you getting this error trying to build or running the APP locally?

The package had some opened Issues about this topic before (#204 & #226). Most of them say to add JCenter() to AllRepositories in Build.gradle but i've already tried and it failed.

Does anyone knows what is happening? Is the package down or something?

nicknamepiyapong commented 1 year ago

Me too

rumax commented 1 year ago

Did you also try mhiew/AndroidPdfViewer solution?

jmorrn commented 1 year ago

I tried the solution of @rumax and it worked.

I've two projects with diferent versions 0.71 and 0.64.

The project with version of 0.64 i had to put the following config at android/app/build.gradle

android{
....

 packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
    }

}
bunnings-kamrul commented 1 year ago

Similar approach as @Jeanluca-Moren0 worked for me. I have made the following changes

  1. upgraded react-native-view-pdf to the latest (0.14.0)
  2. using latest android pdf viewer by adding flowing lines in android/build.gradle
     pdfViewerVersion = "3.2.0-beta.1"
     pdfViewerRepo = "com.github.mhiew"
  3. Also added common shared library resolution in android/app/build.gradle
    android {
    ...
    packagingOptions {
        pickFirst '**/libc++_shared.so'
        pickFirst '**/libfbjni.so'
    }
    }

Hope this helps

valdio commented 1 year ago

A temporary solution is to substitute the underlying android package com.github.barteksc:android-pdf-viewer with another fork of it.

On android/build.gradle add the following:

allprojects{
// .... other code
configurations.all {
         resolutionStrategy {
             dependencySubstitution {
                 substitute module('com.github.barteksc:android-pdf-viewer') using module('com.github.mhiew:android-pdf-viewer:3.2.0-beta.3')
             }
         }
     }
   }
Osmon11 commented 1 year ago

@valdio Received the following error

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

2: Task failed with an exception.

zabojad commented 1 year ago

Similar approach as @Jeanluca-Moren0 worked for me. I have made the following changes

upgraded react-native-view-pdf to the latest (0.14.0) using latest android pdf viewer by adding flowing lines in android/build.gradle pdfViewerVersion = "3.2.0-beta.1" pdfViewerRepo = "com.github.mhiew" Also added common shared library resolution in android/app/build.gradle android { ... packagingOptions { pickFirst '/libc++_shared.so' pickFirst '/libfbjni.so' } } Hope this helps

Worked for me with a RN0.72.4 project, thanks !

TraFost commented 5 months ago

Similar approach as @Jeanluca-Moren0 worked for me. I have made the following changes

  1. upgraded react-native-view-pdf to the latest (0.14.0)
  2. using latest android pdf viewer by adding flowing lines in android/build.gradle
     pdfViewerVersion = "3.2.0-beta.1"
     pdfViewerRepo = "com.github.mhiew"
  1. Also added common shared library resolution in android/app/build.gradle
android {
 ...
    packagingOptions {
        pickFirst '**/libc++_shared.so'
        pickFirst '**/libfbjni.so'
    }
}

Hope this helps

it works, but when i tried to use url. my app suddenly force close. im confused

NightCoderPal commented 2 months ago

Similar approach as @Jeanluca-Moren0 worked for me. I have made the following changes

  1. upgraded react-native-view-pdf to the latest (0.14.0)
  2. using latest android pdf viewer by adding flowing lines in android/build.gradle
     pdfViewerVersion = "3.2.0-beta.1"
     pdfViewerRepo = "com.github.mhiew"
  1. Also added common shared library resolution in android/app/build.gradle
android {
 ...
    packagingOptions {
        pickFirst '**/libc++_shared.so'
        pickFirst '**/libfbjni.so'
    }
}

Hope this helps

This Helped. thanks

kindapath commented 2 months ago

this worked for me i think its quite logical to change the dependency to DImuthuUpe's repository, since he is the new owner of the library and will maintain it


allprojects {
    configurations.configureEach {
        resolutionStrategy {
            dependencySubstitution {
                substitute(module("com.github.barteksc:android-pdf-viewer"))
                    .using(module("com.github.DImuthuUpe:AndroidPdfViewer:2.8.1"))
                    .because("401 error in main repo")
            }
        }
    }
 }