faizalshap / react-native-otp-verify

React native sms verification without additional permissions
MIT License
239 stars 92 forks source link

Build error since Feb 16, 2024 #108

Closed steavenb closed 6 months ago

steavenb commented 6 months ago

I am facing a build error with the latest version since Feb 16. The error is as follows:

`Note: Recompile with -Xlint:deprecation for details. /Users/steavenbc/Documents/codes/ws-mobile/ws-mobile/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java:54: error: cannot find symbol .addApi(Auth.CREDENTIALS_API) ^ symbol: variable CREDENTIALS_API location: class Auth Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 1 error

FAILURE: Build failed with an exception.

Tried lowering the version, to 1.1.4 and 1.1.5 too, but it did not work.

rvcavalcante-tem commented 6 months ago

having the same issues here

jalvarez930 commented 6 months ago

Having the same issue

steavenb commented 6 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-otp-verify@1.1.6 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
index f500410..040ad6b 100644
--- a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
+++ b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
@@ -51,7 +51,7 @@ public class OtpVerifyModule extends ReactContextBaseJavaModule implements Lifec
         registerReceiverIfNecessary(mReceiver);
         reactContext.addActivityEventListener(this);
         apiClient = new GoogleApiClient.Builder(reactContext)
-                .addApi(Auth.CREDENTIALS_API)
+                .addApi(Auth.GOOGLE_SIGN_IN_API)
                 .build();
     }

This issue body was partially generated by patch-package.

AdityaSinghXenelsoft commented 6 months ago

@steavenb i am getting issue patch-package 7.0.0 β€’ Creating temporary folder β€’ Installing react-native-otp-verify@1.1.6 with yarn β€’ Diffing your files with clean files βœ” Created file patches/react-native-otp-verify+1.1.6.patch

node:internal/errors:563 ErrorCaptureStackTrace(err); ^

Error: spawn ENAMETOOLONG at ChildProcess.spawn (node:internal/child_process:421:11) at Object.spawn (node:child_process:761:9) at module.exports [as default] (E:\React-native\goal\node_modules\open\index.js:175:34) { errno: -4064, code: 'ENAMETOOLONG', syscall: 'spawn' }

Node.js v20.11.1

Can you help me ?

IndrakumarR commented 6 months ago

i'm using "react-native-otp-verify": "1.1.4",
I'm also having this issue

KManiKumarReddy commented 6 months ago

@jalvarez930 @steavenb @IndrakumarR @rvcavalcante-tem @AdityaSinghXenelsoft @WooWan Another alternative is to set playServiceVersion to 20.7.0 , this library is checking for this value, if it doesn't exist then it's taking the latest.

Latest version for Google Play Services is 21.0.0 which released today and they have removed the deprecated Credentials API -> https://developers.google.com/android/guides/releases

So downgrading to previous version will fix the issue, that is how we've patched the package for now:

diff --git a/android/build.gradle b/android/build.gradle
index be64dc0fcbcfaaa813b1d4733baf29df5bbbf339..d717878f34ae6eb03f4c1c65066ae62ca615477e 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -54,7 +54,7 @@ repositories {
 }

 dependencies {
-    def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', safeExtGet('playServiceVersion', '+'))
+    def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', safeExtGet('playServiceVersion', '20.7.0'))

     //noinspection GradleDynamicVersion
     implementation "com.facebook.react:react-native:+"  // From node_modules

But then found another alternative which is to set playServiceVersion in your root build.gradle ext block like this

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

buildscript {
    ext {
        buildToolsVersion = "xxx"
        minSdkVersion = "xx"
        compileSdkVersion = "xx"
        ndkVersion = "xxxx"
        playServiceVersion="20.7.0"
    }

CC: @faizalshap

KManiKumarReddy commented 6 months ago

Maybe we can add a section like this in Readme, if we're planning to support this variable: https://github.com/react-native-maps/react-native-maps/blob/bb0855714895e5264f4f6b3ebc9f3cdc6350b39a/docs/installation.md#build-configuration-on-android

faizalshap commented 6 months ago

@KManiKumarReddy if we merge this, i hope it doesn't break existing versions

faizalshap commented 6 months ago

@steavenb can you please send me the documentation link where i can check this

KManiKumarReddy commented 6 months ago

@KManiKumarReddy if we merge this, i hope it doesn't break existing versions

it'll still break existing versions anyway, we'll either have to upgrade to signin api or set default playservices version to 20.7.0, both will need to publish new version anyways.

Only way existing versions will work is to set that value in gradle file and hope it doesn't cause gradle conflicts

shyamaprasadk commented 6 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-otp-verify@1.1.6 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
index f500410..040ad6b 100644
--- a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
+++ b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
@@ -51,7 +51,7 @@ public class OtpVerifyModule extends ReactContextBaseJavaModule implements Lifec
         registerReceiverIfNecessary(mReceiver);
         reactContext.addActivityEventListener(this);
         apiClient = new GoogleApiClient.Builder(reactContext)
-                .addApi(Auth.CREDENTIALS_API)
+                .addApi(Auth.GOOGLE_SIGN_IN_API)
                 .build();
     }

This issue body was partially generated by patch-package.

It works for me πŸ₯³πŸ₯³πŸ₯³

Saliheen commented 6 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-otp-verify@1.1.6 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
index f500410..040ad6b 100644
--- a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
+++ b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
@@ -51,7 +51,7 @@ public class OtpVerifyModule extends ReactContextBaseJavaModule implements Lifec
         registerReceiverIfNecessary(mReceiver);
         reactContext.addActivityEventListener(this);
         apiClient = new GoogleApiClient.Builder(reactContext)
-                .addApi(Auth.CREDENTIALS_API)
+                .addApi(Auth.GOOGLE_SIGN_IN_API)
                 .build();
     }

This issue body was partially generated by patch-package.

it works for me

AdityaSinghXenelsoft commented 6 months ago

@jalvarez930 @steavenb @IndrakumarR @rvcavalcante-tem @AdityaSinghXenelsoft @WooWan Another alternative is to set playServiceVersion to 20.7.0 , this library is checking for this value, if it doesn't exist then it's taking the latest.

Latest version for Google Play Services is 21.0.0 which released today and they have removed the deprecated Credentials API -> https://developers.google.com/android/guides/releases

So downgrading to previous version will fix the issue, that is how we've patched the package for now:

diff --git a/android/build.gradle b/android/build.gradle
index be64dc0fcbcfaaa813b1d4733baf29df5bbbf339..d717878f34ae6eb03f4c1c65066ae62ca615477e 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -54,7 +54,7 @@ repositories {
 }

 dependencies {
-    def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', safeExtGet('playServiceVersion', '+'))
+    def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', safeExtGet('playServiceVersion', '20.7.0'))

     //noinspection GradleDynamicVersion
     implementation "com.facebook.react:react-native:+"  // From node_modules

But then found another alternative which is to set playServiceVersion in your root build.gradle ext block like this

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

buildscript {
    ext {
        buildToolsVersion = "xxx"
        minSdkVersion = "xx"
        compileSdkVersion = "xx"
        ndkVersion = "xxxx"
        playServiceVersion="20.7.0"
    }

CC: @faizalshap

This worked for me

Vikas-EnlitenIT commented 6 months ago

@jalvarez930 @steavenb @IndrakumarR @rvcavalcante-tem @AdityaSinghXenelsoft @WooWan Another alternative is to set playServiceVersion to 20.7.0 , this library is checking for this value, if it doesn't exist then it's taking the latest.

Latest version for Google Play Services is 21.0.0 which released today and they have removed the deprecated Credentials API -> https://developers.google.com/android/guides/releases

So downgrading to previous version will fix the issue, that is how we've patched the package for now:

diff --git a/android/build.gradle b/android/build.gradle
index be64dc0fcbcfaaa813b1d4733baf29df5bbbf339..d717878f34ae6eb03f4c1c65066ae62ca615477e 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -54,7 +54,7 @@ repositories {
 }

 dependencies {
-    def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', safeExtGet('playServiceVersion', '+'))
+    def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', safeExtGet('playServiceVersion', '20.7.0'))

     //noinspection GradleDynamicVersion
     implementation "com.facebook.react:react-native:+"  // From node_modules

But then found another alternative which is to set playServiceVersion in your root build.gradle ext block like this

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

buildscript {
    ext {
        buildToolsVersion = "xxx"
        minSdkVersion = "xx"
        compileSdkVersion = "xx"
        ndkVersion = "xxxx"
        playServiceVersion="20.7.0"
    }

CC: @faizalshap

This worked for me.

navjotsrmtpl commented 6 months ago

Autofilling otp from mobile is not working now startOtpLisner is not able to listen to the events

KManiKumarReddy commented 6 months ago

Autofilling otp from mobile is not working now startOtpLisner is not able to listen to the events

@navjotsrmtpl how did you build the app? did you use the patch-package solution? Downgrading to com.google.android.gms:play-services-auth to 20.7.0 worked for me

kuldip-simform commented 6 months ago

Why are we having this issue all of sudden. I am having same issue. Anyone has idea ?

KManiKumarReddy commented 6 months ago

Why are we having this issue all of sudden. I am having same issue. Anyone has idea ?

@kuldip-simform As I've explained in my comment above https://github.com/faizalshap/react-native-otp-verify/issues/108#issuecomment-1947943784, This library is taking the latest version of com.google.android.gms:play-services-auth which is upgrading to 21.0.0 and according to release notes https://developers.google.com/android/guides/releases they have removed the CREDENTIALS_API , now why we're using CREDENTIALS_API is a question only authors can answer.

technophilix commented 6 months ago

update to version 1.1.18. problem solved.

usamaabutt commented 6 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-otp-verify@1.1.6 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
index f500410..040ad6b 100644
--- a/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
+++ b/node_modules/react-native-otp-verify/android/src/main/java/com/faizal/OtpVerify/OtpVerifyModule.java
@@ -51,7 +51,7 @@ public class OtpVerifyModule extends ReactContextBaseJavaModule implements Lifec
         registerReceiverIfNecessary(mReceiver);
         reactContext.addActivityEventListener(this);
         apiClient = new GoogleApiClient.Builder(reactContext)
-                .addApi(Auth.CREDENTIALS_API)
+                .addApi(Auth.GOOGLE_SIGN_IN_API)
                 .build();
     }

This issue body was partially generated by patch-package.

This works for me, and I was using an old version 1.0.5 so I also jumped to the latest version now.

AminDannak commented 6 months ago

just upgraded to version 1.1.8 and build was successful

paveltar commented 6 months ago

just upgraded to version 1.1.8 and build was successful

But does the auto otp fill work for you?

nguyenanhtuan0799 commented 6 months ago

playServiceVersion="20.7.0"

this works for me πŸŽ‰