razorpay / react-native-razorpay

React Native wrapper for Razorpay's mobile SDKs
https://www.npmjs.com/package/react-native-razorpay
MIT License
121 stars 107 forks source link

Jitpack - Android build fails when building on EAS Expo #432

Closed karanmartian closed 1 year ago

karanmartian commented 1 year ago

Currently Jitpack is down and its uptime is always a concern. With this library hosted on Jitpack, EAS Expo build is not able to download the library and the build fails. Could you please help? As the entire app cannot be built because of this.

137[stderr] > Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'. 138[stderr] > Could not resolve com.razorpay:checkout:1.6.+. 139[stderr] Required by: 140[stderr] project :app > project :react-native-razorpay 141[stderr] > Failed to list versions for com.razorpay:checkout. 142[stderr] > Unable to load Maven meta-data from https://www.jitpack.io/com/razorpay/checkout/maven-metadata.xml. 143[stderr] > Could not GET 'https://www.jitpack.io/com/razorpay/checkout/maven-metadata.xml'. Received status code 521 from server:

vivekshindhe commented 1 year ago

@karanmartian Razorpay sdk doesn't depend on Jitpack. MavenCentral is the used repository. Can you please share your build.gradle(root) file to check further?

vivekshindhe commented 1 year ago

Also, Can you try running it after removing the line maven { url 'https://www.jitpack.io' } in build.gradle (root level) and running it? If there are no dependencies that depend on jitpack it should build fine.

wodin commented 1 year ago

FYI, JitPack is back up, and builds involving react-native-razorpay started working again. I don't understand why the JitPack outage affected Razorpay.

I got this error when building a managed Expo app. The app's android/build.gradle that is generated during the build process on Expo's "EAS Build" servers looks like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
        minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
        compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
        if (findProperty('android.kotlinVersion')) {
            kotlinVersion = findProperty('android.kotlinVersion')
        }
        frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'

        if (System.properties['os.arch'] == 'aarch64') {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = '24.0.8215888'
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = '21.4.7075529'
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.2.1')
        classpath('com.facebook.react:react-native-gradle-plugin')
        classpath('de.undercouch:gradle-download-task:5.0.1')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
        }
        maven {
            // Android JSC is installed from npm
            url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
        }

        google()
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup 'com.facebook.react'
            }
        }
        maven { url 'https://www.jitpack.io' }
    }
}

Given that jitpack.io is listed last I would have thought it would not affect anything hosted on Maven Central or one of the other Maven repositories. But somehow Gradle tried to download com.razorpay:checkout from JitPack. I don't understand why that is.

vivekshindhe commented 1 year ago

We'll be looking into this, closing this ticket for now. I appreciate your patience.