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

Fix compileSdkVersion and buildToolsVersion

Open AdeilsonESilva opened this issue 3 years ago • 1 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.

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..cd346bd 100644
--- a/node_modules/react-native-orientation/android/build.gradle
+++ b/node_modules/react-native-orientation/android/build.gradle
@@ -1,8 +1,12 @@
+def safeExtGet(prop, fallback) {
+    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
+}
+
 apply plugin: 'com.android.library'
 
 android {
-    compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    compileSdkVersion safeExtGet('compileSdkVersion', 23)
+    buildToolsVersion safeExtGet('buildToolsVersion', "23.0.1")
 
     defaultConfig {
         minSdkVersion 16

AdeilsonESilva avatar Sep 14 '21 19:09 AdeilsonESilva

I have a better solution

rootProject/android/build.gradle

subprojects {
    afterEvaluate {subProject ->
        if (subProject.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

Alan0725 avatar Dec 17 '21 02:12 Alan0725