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

buildscript {
    ext {
// @generated begin expo-gradle-ext-vars - expo prebuild (DO NOT MODIFY) sync-a14167d3df9d6380c3d77a8f8070215ea8a94013
	googlePlayServicesLocationVersion = "21.1.0"
	appCompatVersion = "1.4.2"
// @generated end expo-gradle-ext-vars
        // buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
        minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
        compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '35')
        kotlinVersion = findProperty('android.kotlinVersion') ?: '2.0.21'

        ndkVersion = "27.2.12479018"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.4.1'
        classpath('com.android.tools.build:gradle:8.6.0')
        classpath('com.facebook.react:react-native-gradle-plugin')
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
    }
}

apply plugin: "com.facebook.react.rootproject"

allprojects {
    repositories {
maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
        }
        maven {
            // Android JSC is installed from npm
            url(new File(['node', '--print', "require.resolve('jsc-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), '../dist'))
        }

        google()
        mavenCentral()
        maven { url 'https://www.jitpack.io' }
        maven {
            url "$rootDir/../node_modules/@notifee/react-native/android/libs"
        }
        
        // https://github.com/Lyokone/flutterlocation/issues/802#issuecomment-1415980821
        // configurations.all {
        //     resolutionStrategy {
        //         force "com.google.android.gms:play-services-location:21.0.1"
        //     }
        // }

         maven {
           url("$rootDir/../node_modules/detox/Detox-android")
         }
    }
}

/**
 * Force 16KB page size at link time for all subprojects that build native code with CMake.
 * Use projectsEvaluated to avoid afterEvaluate on already-evaluated projects.
 */
gradle.projectsEvaluated {
    subprojects { proj ->
        def androidExt = proj.extensions.findByName("android")
        if (androidExt != null &&
            androidExt.hasProperty("externalNativeBuild") &&
            androidExt.externalNativeBuild?.cmake != null) {
            try {
                def flag = "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384"
                def args = androidExt.externalNativeBuild.cmake.arguments
                if (args == null || args.isEmpty()) {
                    androidExt.externalNativeBuild.cmake.arguments = [flag]
                } else if (!args.contains(flag)) {
                    androidExt.externalNativeBuild.cmake.arguments += flag
                }
            } catch (Throwable ignored) {
                // ignore if structure differs for a subproject
            }
        }
    }
}
