react-native-orientation icon indicating copy to clipboard operation
react-native-orientation copied to clipboard

fix android build.gradle and fix receiver API 34

Open AngelKrak opened this issue 7 months ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Updated [email protected] configuration to dynamically set SDK versions, improve dependency management, and enhance security in Android.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-orientation/android/build.gradle b/node_modules/react-native-orientation/android/build.gradle
index e09fb27..aaf30a6 100644
--- a/node_modules/react-native-orientation/android/build.gradle
+++ b/node_modules/react-native-orientation/android/build.gradle
@@ -1,20 +1,20 @@
 apply plugin: 'com.android.library'
 
 android {
-    compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : 23
+    buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : "23.0.1"
 
     defaultConfig {
-        minSdkVersion 16
-        targetSdkVersion 22
+        minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : 16
+        targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : 22
         versionCode 1
         versionName "1.0"
-        ndk {
-            abiFilters "armeabi-v7a", "x86"
-        }
+        // ndk {
+        //     abiFilters "armeabi-v7a", "x86"
+        // }
     }
 }
 
 dependencies {
-    compile "com.facebook.react:react-native:+"
+    implementation "com.facebook.react:react-native:+"
 }
diff --git a/node_modules/react-native-orientation/android/src/main/java/com/github/yamill/orientation/OrientationModule.java b/node_modules/react-native-orientation/android/src/main/java/com/github/yamill/orientation/OrientationModule.java
index 85331ae..3df9a1f 100644
--- a/node_modules/react-native-orientation/android/src/main/java/com/github/yamill/orientation/OrientationModule.java
+++ b/node_modules/react-native-orientation/android/src/main/java/com/github/yamill/orientation/OrientationModule.java
@@ -150,7 +150,7 @@ public class OrientationModule extends ReactContextBaseJavaModule implements Lif
             FLog.e(ReactConstants.TAG, "no activity to register receiver");
             return;
         }
-        activity.registerReceiver(receiver, new IntentFilter("onConfigurationChanged"));
+        activity.registerReceiver(receiver, new IntentFilter("onConfigurationChanged"), Context.RECEIVER_NOT_EXPORTED);
     }
     @Override
     public void onHostPause() {

This issue body was partially generated by patch-package.

AngelKrak avatar Jul 05 '24 00:07 AngelKrak