react-native-pdf icon indicating copy to clipboard operation
react-native-pdf copied to clipboard

Can't build, 502 error

Open DtheRock opened this issue 4 years ago • 13 comments

What react-native version are you using? 0.66.4 What react-native-pdf version are you using? 6.3.0 What platform does your issue occur on? (android/ios/both) android Describe your issue as precisely as possible :

Since today I am unable to build anymore. The below error appears on the log file.

  • What went wrong: A problem occurred configuring project ':react-native-pdf'.

Could not resolve all artifacts for configuration ':react-native-pdf:classpath'. Could not resolve com.android.tools.build:gradle:3.1.4. Required by: project :react-native-pdf > Could not resolve com.android.tools.build:gradle:3.1.4. > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom'. > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom'. Received status code 502 from server: Bad Gateway

Join a screenshot or video of the problem on the simulator or device?

Show us the code you are using?

DtheRock avatar Jan 12 '22 21:01 DtheRock

It's because jcenter() is deprecated.

damian-balas avatar Jan 12 '22 21:01 damian-balas

I don't use the jcenter in my build.gradle file.

DtheRock avatar Jan 12 '22 21:01 DtheRock

it's in your node_modules/react-native-pdf/android/build.gradle file. Change jcenter() to mavenCentral() and apply it with patch-package

damian-balas avatar Jan 12 '22 21:01 damian-balas

I am building through the appcenter, so there is no node modules folder locally, and as far as I know, the appcenter is doing a clean installation on every new build. In addition, I've changed the node version in the appcenter, in order to initiate a clean build. The issue still remains, however.

DtheRock avatar Jan 12 '22 22:01 DtheRock

If you don't have access to node_modules then I can't help you :( This is the only fix I'm aware of.

damian-balas avatar Jan 12 '22 22:01 damian-balas

I am building through the appcenter, so there is no node modules folder locally, and as far as I know, the appcenter is doing a clean installation on every new build. In addition, I've changed the node version in the appcenter, in order to initiate a clean build. The issue still remains, however.

Hello, Im compiling too in App Center and the answer @damian-balas worked for me In my code I access the node_modules, made the change suggested by him and then run the npx patch-package react-native-pdf then commiting the new file to the repo and compiling again on App Center

ericMaxon avatar Jan 12 '22 22:01 ericMaxon

We are seeing this error too ever since we upgraded to RN 0.66.4 and removed jcenter() from our build.gradle repositories (replacing it with mavencentral). In the meantime, we should be able to fix this by adding jcenter() back in our app's build.gradle, but this repo should probably move its build.gradle over to mavencentral.

roryabraham avatar Jan 13 '22 00:01 roryabraham

Oops, my last comment wasn't entirely correct. This repo already moved over from jcenter to mavencentral: https://github.com/wonday/react-native-pdf/pull/606

It just hasn't been included in a release yet.

roryabraham avatar Jan 13 '22 00:01 roryabraham

@ericMaxon Thanks, bro. you saved me!

DtheRock avatar Jan 13 '22 01:01 DtheRock

I think maybe an easier solution for y'all than manually editing your node_modules might be to just point your package.json at the latest git commit for this repo instead of the latest release. Just my two cents, hope it helps 🙂

roryabraham avatar Jan 13 '22 01:01 roryabraham

Can I suggest re-opening this until a new version of react-native-pdf that contains https://github.com/wonday/react-native-pdf/pull/606 has been released?

cc @wonday – JCenter did another brownout (as expected per their shutdown plans) and builds failed for a bunch of Android apps that use react-native-pdf. Can you release a new version of this package with https://github.com/wonday/react-native-pdf/pull/606 in it? Also, thank you for the excellent library! ❤️

nchase avatar Jan 13 '22 16:01 nchase

@wonday Pls push new release, community needs this update like said @nchase. Also thanks for you work!

rastuch avatar Jan 17 '22 14:01 rastuch

Please update this PR when the release with #606 is out.

For now what we can do:

  1. Go to node_modules/react-native-pdf/android/build.gradle
  2. Change jcenter() to mavenCentral()
  3. Use patch package to make sure it updates after every install: npx patch-package react-native-pdf
  4. Git add, commit and push

Notes:

  • Add --use-yarn to patch-package command in case your project uses Yarn.
  • In case of dependencies are not added to Maven, here is instructions on how to add: https://maven.apache.org/repository/guide-central-repository-upload.html

sayurimizuguchi avatar Jan 17 '22 20:01 sayurimizuguchi