Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android build error with latest RN version 0.72.1 #185

Closed
mlazari opened this issue Jul 10, 2023 · 3 comments 路 Fixed by #186
Closed

Android build error with latest RN version 0.72.1 #185

mlazari opened this issue Jul 10, 2023 · 3 comments 路 Fixed by #186

Comments

@mlazari
Copy link
Contributor

mlazari commented Jul 10, 2023

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch react-native-azure-auth@1.8.8 for the project I'm working on.

After updating my project to the latest version of React Native 0.72.1 I started getting this error on Android:

* What went wrong:
Could not determine the dependencies of task ':react-native-azure-auth:bundleLibCompileToJarDebug'.
> Could not create task ':react-native-azure-auth:compileDebugJavaWithJavac'.
   > In order to compile Java 9+ source, please set compileSdkVersion to 30 or above

I have this in android/build.gradle, but react-native-azure-auth is ignoring it and always uses compileSdkVersion 29:

buildscript {
    ext {
        // ...
        compileSdkVersion = 33
        // ...
    }
    // ...
}

Other libraries use the values from android/build.gradle, so I did a patch to solve this issue similarly in this library.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-azure-auth/android/build.gradle b/node_modules/react-native-azure-auth/android/build.gradle
index 0814ea0..34c83b7 100644
--- a/node_modules/react-native-azure-auth/android/build.gradle
+++ b/node_modules/react-native-azure-auth/android/build.gradle
@@ -1,7 +1,3 @@
-project.ext {
-    buildToolsVersion = "28.0.3"
-}
-
 buildscript {
     repositories {
         jcenter()
@@ -15,13 +11,17 @@ buildscript {
 
 apply plugin: 'com.android.library'
 
+def safeExtGet(prop, fallback) {
+    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
+}
+
 android {
-    compileSdkVersion 29
-    buildToolsVersion "${project.ext.buildToolsVersion}"
+    compileSdkVersion safeExtGet('compileSdkVersion', 29)
+    buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
 
     defaultConfig {
         minSdkVersion 16
-        targetSdkVersion 29
+        targetSdkVersion safeExtGet('targetSdkVersion', 29)
         versionCode 1
         versionName "1.0"
     }

This issue body was partially generated by patch-package.

mlazari added a commit to mlazari/react-native-azure-auth that referenced this issue Jul 10, 2023
vmurin pushed a commit that referenced this issue Jul 15, 2023
@vmurin
Copy link
Owner

vmurin commented Jul 15, 2023

Thank you very much for your contribution! 馃檹馃徎

@andrei-tectu
Copy link

andrei-tectu commented Jul 20, 2023

You are amazing. I used this to fix my e2e test with Detox.
In my case was minSdkVersion error so I used it also for

minSdkVersion safeExtGet('minSdkVersion', 16)

Thank you

@DevJoelito
Copy link

Thank you for this!馃嵒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants