// android/build.gradle
buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath("com.android.tools.build:gradle:8.5.1")
    }
}

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 35
    buildToolsVersion safeExtGet('buildToolsVersion', '34.0.0')
    ndkVersion "26.1.10909125"
    
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 21)
        targetSdkVersion 35
        versionCode 1
        versionName "1.0"
        
        externalNativeBuild {
            cmake {
              cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all -std=c++17 -DNO_INCBIN -DUSE_PTHREADS -DNDEBUG"
              abiFilters "arm64-v8a", "armeabi-v7a", "x86_64", "x86"
              arguments "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
            }
        }
        
        ndk {
            abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64', 'x86'
        }
    }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    
    externalNativeBuild {
        cmake {
            path "./CMakeLists.txt"
            version "3.22.1"
        }
    }
    
    packagingOptions {
        pickFirst '**/*.so'
        jniLibs {
            useLegacyPackaging = false
        }
    }
}

dependencies {
    implementation "com.facebook.react:react-native:+"
}