faizalshap / react-native-otp-verify

React native sms verification without additional permissions
MIT License
252 stars 96 forks source link

Unable to build #5

Closed kashishgrover closed 3 years ago

kashishgrover commented 5 years ago

I tried to integrate this with our React Native project and I got the following error

FAILURE: Build failed with an exception.

* Where:
Build file '........................./node_modules/react-native-otp-verify/android/build.gradle' line: 37

* What went wrong:
A problem occurred evaluating project ':react-native-otp-verify'.
> Could not find method google() for arguments [] on repository container.

We currently use React Native v0.52 in our app so yeah we are pretty far behind. Does that mean I cannot use this until we upgrade React Native? Are these two things related?

Dror-Bar commented 5 years ago

Inside your node_modules folder, find react-native-otp-verify --> android --> build.gradle. It will look like this:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
    }
}

...

repositories {
    mavenCentral()
    google()            //   <------ Remove this
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}

dependencies {
    def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion
            : project.hasProperty('playServiceVersion') ? project.playServiceVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
    implementation 'com.facebook.react:react-native:+'
    implementation "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
}

Next, it will probably prompt you about implementation. So change both of those to compile instead. However, I still don't think this will work for you. It's better not to change this file and update your build tools to 3.1.4, then everything will work.

kashishgrover commented 5 years ago

@Dror-Bar thanks for that, but I still don't think it would work. In the dependencies it uses 'implementation' keyword which is not compatible with our current gradle version. For now, I will simply try and implement the java files of this project in my project as a local dependency. Because we cannot upgrade react native right now, when we do, I will add this back as it is

faizalshap commented 5 years ago

I thinks this has to do with build gradle version as old gradle version does not have google() (Not an expert so might be wrong). Check the comment here it may solve your issue - #https://github.com/react-native-community/react-native-svg/issues/584#issuecomment-359260761

kashishgrover commented 5 years ago

@faizalshap yeah it probably does have to do with that. I wonder how certain packages are not dependent on the gradle versions. Is that somehow possible here as well?

faizalshap commented 5 years ago

Not sure i'll have to look into it once i get some freetime...