react-native-sms-user-consent icon indicating copy to clipboard operation
react-native-sms-user-consent copied to clipboard

Breaks with Gradle 7 (maven), RN 0.68

Open hirbod opened this issue 2 years ago • 4 comments

Hi,

I just upgraded to RN68 and the plugin is breaking unfortunately due to the usage of maven. Here are the required patches. Is this library still maintained @akvelon ?

If not, I would fork it and re-release.

Here is the diff that solved my problem:

diff --git a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle
index 70807f5..2577a40 100644
--- a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle
+++ b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle
@@ -20,7 +20,6 @@ def safeExtGet(prop, fallback) {
 }
 
 apply plugin: 'com.android.library'
-apply plugin: 'maven'
 
 buildscript {
     // The Android Gradle plugin is only required when opening the android folder stand-alone.
@@ -39,7 +38,6 @@ buildscript {
 }
 
 apply plugin: 'com.android.library'
-apply plugin: 'maven'
 
 android {
     compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
@@ -56,16 +54,6 @@ android {
 }
 
 repositories {
-    // ref: https://www.baeldung.com/maven-local-repository
-    mavenLocal()
-    maven {
-        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
-        url "$rootDir/../node_modules/react-native/android"
-    }
-    maven {
-        // Android JSC is installed from npm
-        url "$rootDir/../node_modules/jsc-android/dist"
-    }
     google()
     jcenter()
 }
@@ -111,7 +99,7 @@ afterEvaluate { project ->
     task androidJavadoc(type: Javadoc) {
         source = android.sourceSets.main.java.srcDirs
         classpath += files(android.bootClasspath)
-        classpath += files(project.getConfigurations().getByName('compile').asList())
+        //classpath += files(project.getConfigurations().getByName('compile').asList())
         include '**/*.java'
     }
 
@@ -142,10 +130,5 @@ afterEvaluate { project ->
 
     task installArchives(type: Upload) {
         configuration = configurations.archives
-        repositories.mavenDeployer {
-            // Deploy to react-native-event-bridge/maven, ready to publish to npm
-            repository url: "file://${projectDir}/../android/maven"
-            configureReactNativePom pom
-        }
     }
 }
diff --git a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java
index c8d829a..6a668ca 100644
--- a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java
+++ b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java
@@ -118,6 +118,17 @@ public class ReactNativeSmsUserConsentModule extends ReactContextBaseJavaModule
             .emit(AKV_SMS_RETRIEVE_ERROR, params);
     }
 
+    // Required for rn built in EventEmitter Calls.
+    @ReactMethod
+    public void addListener(String eventName) {
+
+    }
+
+    @ReactMethod
+    public void removeListeners(Integer count) {
+
+    }
+
     @ReactMethod
     public void startNativeSmsListener(Promise promise) {
         try {

This issue body was partially generated by patch-package.

hirbod avatar Apr 27 '22 23:04 hirbod

@hirbod Hi! Can't reproduce this error on my side, got RN0.68 installed with gradle 7 with my mock project and do not experience this problem

SuyunSarbayev avatar Jul 07 '22 05:07 SuyunSarbayev

@hirbod Can you give more details about your build, project structure, the error message appears after you trying to build your gradle view command ./gradle build inside RN068RC2 package?

SuyunSarbayev avatar Jul 07 '22 10:07 SuyunSarbayev

I'll dig into this at some other point but without these patches it was not possible to install it on 0.68.2 with Expo and a custom dev client

hirbod avatar Jul 07 '22 13:07 hirbod

Same thing happened to my app, in the version 0.69 of react. With this patch worked fine

joaohd98 avatar Jul 12 '22 16:07 joaohd98