react-native-netinfo / react-native-netinfo

React Native Network Info API for Android & iOS
MIT License
1.99k stars 394 forks source link

Android build issue with Gradle 8.0.1 and react native 0.72.1 #679

Open chganesh opened 1 year ago

chganesh commented 1 year ago

Environment

Platforms

Versions

Description

Task failed with an exception.

2: Task failed with an exception.

3: Task failed with an exception.

4: Task failed with an exception.

5: Task failed with an exception.

6: Task failed with an exception.

7: Task failed with an exception.

8: Task failed with an exception.

9: Task failed with an exception.

10: Task failed with an exception.

11: Task failed with an exception.

12: Task failed with an exception.

13: Task failed with an exception.

14: Task failed with an exception.

15: Task failed with an exception.

16: Task failed with an exception.

17: Task failed with an exception.

18: Task failed with an exception.

19: Task failed with an exception.

20: Task failed with an exception.

21: Task failed with an exception.

philly25 commented 1 year ago

If libraries that cause these errors are listed in android/app/build.gradle in dependencies - remove them.

I've had to remove just this one:

dependencies {
...
//  implementation project(':@react-native-community_netinfo')
...
}
cw-sanjeev commented 1 year ago

@chganesh have same issue, did you manage to solve it?

eithe commented 1 year ago

@philly25 Was on to something in my case, but I also needed to update settings.gradle. I added netinfo way back when autolinking wasn't a thing so I had:

android/app/build.gradle

dependencies {
  ...
  implementation project(":react-native-community/netinfo")
  ...
}

android/settings.gradle

...
include ":react-native-community-netinfo"
project(":react-native-community-netinfo").projectDir = new File(rootProject.projectDir, "../node_modules/@react-native-community/netinfo/android")
...

Previously gradlew/Android building didn't give an error on that, but after upgrading to Gradle 8.0.1 with RN 0.72.x it started doing so.

Simply removing the mentioned lines in both files (thus relying on autolinking) resolved the issue. I also had to do the same for other packages (like @react-native-async-storage) I added before autolinking.