heap / react-native-heap

A React Native integration for Heap
MIT License
82 stars 36 forks source link

Issues with jcenter() in build.gradle #312

Closed benmagos closed 2 years ago

benmagos commented 2 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @heap/react-native-heap@0.20.0 for the project I'm working on.

For some reason, it appears that once gradle tries to find these dependencies via jcenter, it does not move along to look in google, and resulted in the following failure.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':heap_react-native-heap'.
> Could not resolve all artifacts for configuration ':heap_react-native-heap:classpath'.
   > Could not resolve com.android.tools:annotations:26.2.1.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:shared:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:crash:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > androidx.databinding:databinding-compiler-common:3.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools.build:builder-model:3.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:common:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools.analytics-library:tracker:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1 > com.android.tools.layoutlib:layoutlib-api:26.2.1
      > Could not resolve com.android.tools:annotations:26.2.1.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/annotations/26.2.1/annotations-26.2.1.pom'.
            > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/annotations/26.2.1/annotations-26.2.1.pom'.
               > Read timed out
   > Could not resolve org.apache.httpcomponents:httpmime:4.5.2.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:crash:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1
      > Skipped due to earlier error
   > Could not resolve org.apache.httpcomponents:httpcore:4.4.5.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:crash:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1
      > Skipped due to earlier error
   > Could not resolve org.apache.httpcomponents:httpclient:4.5.2.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:crash:26.2.1
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.2.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.lint:lint-gradle-api:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdk-common:26.2.1
      > Skipped due to earlier error
   > Could not resolve org.antlr:antlr4:4.5.3.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > androidx.databinding:databinding-compiler-common:3.2.1
      > Skipped due to earlier error
   > Could not resolve commons-io:commons-io:2.4.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > androidx.databinding:databinding-compiler-common:3.2.1
      > Skipped due to earlier error
   > Could not resolve com.googlecode.juniversalchardet:juniversalchardet:1.0.3.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > androidx.databinding:databinding-compiler-common:3.2.1
      > Skipped due to earlier error
   > Could not resolve com.squareup:javapoet:1.8.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > androidx.databinding:databinding-compiler-common:3.2.1
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.2.71.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71
      > Skipped due to earlier error
   > Could not resolve net.sf.proguard:proguard-base:6.0.3.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > net.sf.proguard:proguard-gradle:6.0.3
      > Skipped due to earlier error
   > Could not resolve com.google.auto.value:auto-value:1.5.2.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:bundletool:0.5.0
      > Skipped due to earlier error
   > Could not resolve com.google.errorprone:error_prone_annotations:2.2.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:bundletool:0.5.0
      > Skipped due to earlier error
   > Could not resolve com.google.protobuf:protobuf-java:3.4.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:bundletool:0.5.0
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdk-common:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools.analytics-library:protos:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools.analytics-library:tracker:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:bundletool:0.5.0 > com.android.tools.build:aapt2-proto:0.3.1
      > Skipped due to earlier error
   > Could not resolve com.google.protobuf:protobuf-java-util:3.4.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:bundletool:0.5.0
      > Skipped due to earlier error
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.2.71.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build.jetifier:jetifier-core:1.0.0-alpha10
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10
      > Skipped due to earlier error
   > Could not resolve org.jdom:jdom2:2.0.6.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10
      > Skipped due to earlier error
   > Could not resolve org.apache.commons:commons-compress:1.12.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1 > com.android.tools:repository:26.2.1
      > Skipped due to earlier error
   > Could not resolve javax.inject:javax.inject:1.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdk-common:26.2.1
      > Skipped due to earlier error
   > Could not resolve net.sf.kxml:kxml2:2.3.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools.build:manifest-merger:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools.ddms:ddmlib:26.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1 > com.android.tools.layoutlib:layoutlib-api:26.2.1
      > Skipped due to earlier error
   > Could not resolve com.google.code.findbugs:jsr305:1.3.9.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools.build:apkzlib:3.2.1
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:shared:26.2.1 > com.google.guava:guava:23.0
      > Skipped due to earlier error
   > Could not resolve com.google.errorprone:error_prone_annotations:2.2.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:shared:26.2.1 > com.google.guava:guava:23.0
      > Skipped due to earlier error
   > Could not resolve com.google.j2objc:j2objc-annotations:1.1.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:shared:26.2.1 > com.google.guava:guava:23.0
      > Skipped due to earlier error
   > Could not resolve org.codehaus.mojo:animal-sniffer-annotations:1.14.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.analytics-library:shared:26.2.1 > com.google.guava:guava:23.0
      > Skipped due to earlier error
   > Could not resolve org.jetbrains:annotations:13.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1 > com.android.tools.layoutlib:layoutlib-api:26.2.1
      > Skipped due to earlier error
   > Could not resolve com.sun.activation:javax.activation:1.2.0.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1 > com.android.tools:repository:26.2.1
      > Skipped due to earlier error
   > Could not resolve org.glassfish.jaxb:jaxb-runtime:2.2.11.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1 > com.android.tools:repository:26.2.1
      > Skipped due to earlier error
   > Could not resolve com.google.jimfs:jimfs:1.1.
     Required by:
         project :heap_react-native-heap > com.android.tools.build:gradle:3.2.1 > com.android.tools.build:builder:3.2.1 > com.android.tools:sdklib:26.2.1 > com.android.tools:repository:26.2.1
      > Skipped due to earlier error

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3m 37s

Switching the order of the repositories fixed the issue for us. However, I would imagine removing jcenter() completely would be a better goal to aim for.

Here is the diff that solved my problem:

diff --git a/node_modules/@heap/react-native-heap/android/build.gradle b/node_modules/@heap/react-native-heap/android/build.gradle
index 576b441..4a8c1ad 100644
--- a/node_modules/@heap/react-native-heap/android/build.gradle
+++ b/node_modules/@heap/react-native-heap/android/build.gradle
@@ -37,8 +37,8 @@ def heapAppId(buildType) {

 buildscript {
     repositories {
-        jcenter()
         google()
+        jcenter()
     }

     dependencies {
@@ -75,8 +75,8 @@ android {

 repositories {
     mavenCentral()
-    jcenter()
     google()
+    jcenter()
 }

 dependencies {

This issue body was partially generated by patch-package.

IonoclastBrigham commented 2 years ago

I could see an argument for keeping jcenter as a fallback in the case that google's maven repo goes down, but that will definitely reach a point in the not-too-distant future where it's just too out of date to be useful.