marcshilling / react-native-idle-timer

A cross-platform bridge that allows you to enable and disable the screen idle timer in your React Native app
MIT License
216 stars 41 forks source link

Gradle Version Requirements #26

Closed copiri-six closed 3 years ago

copiri-six commented 3 years ago

I am building a project in Android studio and am running into a circular dependency.

Every time I set my Gradle Plugin and AGP versions to 7.0.2, the build fails because react-native-idle-timer requires v7.0.1. When I downgrade to v7.0.1 in both plugins, the buid fails because the Minimum supported Gradle version is 7.0.2.

I'm pretty new to Android studio and not sure if it's a straightforward adjustment in this project to allow support for the latest Gradle/Android Gradle plugins. Any ideas?

Thanks!

copiri-six commented 3 years ago

After a little more digging... maybe I found the culprit?

This line in the project's build.gradle file references jcenter as the project's repository. Here is my error when building with v7.0.1:

Could not find com.android.tools.build:gradle:7.0.1.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/tools/build/gradle/7.0.1/gradle-7.0.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
    project :react-native-idle-timer

Going to the bintray.com link gives a 403 Forbidden error. So does the project's record at jcenter need to be updated? I suppose I could clone the project and update it myself, but that's not sustainable in the long run. Thanks for any thoughts you have!

marcshilling commented 3 years ago

Hey @copiri-six, could you try out the gradle-fix branch I just pushed up?

You should be able to point your package.json dependency directly at it: "react-native-idle-timer": "marcshilling/react-native-idle-timer#gradle-fix"

If that resolves it, I'll merge it in and push a new version to npm

copiri-six commented 3 years ago

Thanks for the quick response @marcshilling! That's changed my outcome, but I still haven't been able to figure my way through it. :-/

The new build gives me these errors:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '[PROJECT]/node_modules/react-native-reanimated/android/build.gradle' line: 23

* What went wrong:
A problem occurred evaluating project ':react-native-reanimated'.
> Plugin with id 'maven' not found.

==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> compileSdkVersion is not specified. Please add it to build.gradle

==============================================================================

I assume the second one is just a result of the first because you clearly have compileSdkVersion specified here. But I'm not sure where the maven plugin should be coming from.

If i delete the apply plugin: 'maven' line, that fails for other reasons... but i kind of expected that.

Thanks in advance for any ideas you have, and my apologies if these are newbie questions. As a side note -- i'm also getting warnings from Android Studio that jcenter() is no longer maintained, and i should replace those bits with mavenCentral(). I tried that just in case, but no difference in the build failures. FWIW i've also tried downgrading to Gradle 6.9, but then my build blows up for about 20 unrelated reasons (other requirements), so that's not a good option for me.

Thanks again!

copiri-six commented 3 years ago

Does this have anything to do with the current issue?

So it seems the maven plugin is deprecated in gradle 7 (in favor of maven-publish) [...]

marcshilling commented 3 years ago

@copiri-six yeah at this point it seems like it's an issue with react-native-reanimated...I'd follow that thread.

copiri-six commented 3 years ago

@marcshilling i thought you might say that. :-/ On the bright side, it seems that your update worked, so I'm assuming this issue can be closed? Thanks for taking a look!

mattiamari commented 3 years ago

I have issues compiling today because jcenter is down. The gradle-fix branch works though. Since jcenter is deprecated anyway (see this), I would remove it once and for all from build.gradle and publish a new version.

marcshilling commented 3 years ago

@mattiamari thanks for confirming that branch works for you. I will merge that in and publish a new version shortly!

marcshilling commented 3 years ago

v2.1.7 is up on npm with these changes. I didn't remove the jcenter() call because it would not build without it. It's deprecated in that new packages will no longer be added to it, but it contains old ones that we need.