diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 1eb4a61d2..78d51e209 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ Branch-SDK-TestBed/gradlew Branch-SDK-TestBed/gradlew.bat Branch-SDK-TestBed/gradle/wrapper/gradle-wrapper.properties + +.direnv \ No newline at end of file diff --git a/Branch-SDK/build.gradle.kts b/Branch-SDK/build.gradle.kts index ad874f3af..1040ccbb8 100644 --- a/Branch-SDK/build.gradle.kts +++ b/Branch-SDK/build.gradle.kts @@ -62,6 +62,7 @@ dependencies { } val VERSION_NAME: String by project +val ANDROID_BUILD_TOOLS_VERSION: String by project val ANDROID_BUILD_SDK_VERSION_COMPILE: String by project val ANDROID_BUILD_SDK_VERSION_MINIMUM: String by project val VERSION_CODE: String by project @@ -72,7 +73,7 @@ fun isReleaseBuild(): Boolean { android { compileSdk = ANDROID_BUILD_SDK_VERSION_COMPILE.toInt() - + buildToolsVersion = ANDROID_BUILD_TOOLS_VERSION defaultConfig { minSdk = ANDROID_BUILD_SDK_VERSION_MINIMUM.toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..c079805f0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,185 @@ +{ + "nodes": { + "android": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1720988215, + "narHash": "sha256-nQ0Zx0vAWJo0IOGNFjCOdIkDSgOpMa//GalR8tbTl3A=", + "owner": "tadfisher", + "repo": "android-nixpkgs", + "rev": "5a052c62cdb51b210bc0717177d5bd014cba3df1", + "type": "github" + }, + "original": { + "owner": "tadfisher", + "repo": "android-nixpkgs", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "android", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717408969, + "narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", + "owner": "numtide", + "repo": "devshell", + "rev": "1ebbe68d57457c8cae98145410b164b5477761f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1720768451, + "narHash": "sha256-EYekUHJE2gxeo2pM/zM9Wlqw1Uw2XTJXOSAO79ksc4Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7e7c39ea35c5cdd002cd4588b03a3fb9ece6fad9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1722467660, + "narHash": "sha256-aFTieaJ7Sz/t07MFxxq4u5JcKjXz/+VpfALWXKB4vFo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c089f552b84bfb0cd40b5bdca95f21e57b93ffd7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "android": "android", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..b11583ba1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + description = "Branch Android SDK for deep linking and attribution"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + android.url = "github:tadfisher/android-nixpkgs"; + }; + + outputs = { self, nixpkgs, flake-utils, android }: flake-utils.lib.eachSystem [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ] (system: + let + inherit (nixpkgs) lib; + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + overlays = [ + (final: prev: { + android-sdk = android.sdk.${system} (sdkPkgs: with sdkPkgs; [ + build-tools-34-0-0 + cmdline-tools-latest + emulator + platform-tools + platforms-android-34 + ] + ++ lib.optionals (system == "aarch64-darwin") [ + system-images-android-34-google-apis-arm64-v8a + ] + ++ lib.optionals (system == "x86_64-darwin" || system == "x86_64-linux") [ + system-images-android-34-google-apis-x86-64 + ]); + }) + ]; + }; + in + { + formatter = pkgs.nixpkgs-fmt; + devShells = { + default = pkgs.mkShell { + name = "branch-sdk-android"; + ANDROID_HOME = "${pkgs.android-sdk}/share/android-sdk"; + ANDROID_SDK_ROOT = "${pkgs.android-sdk}/share/android-sdk"; + JAVA_HOME = "${pkgs.jdk17.home}"; + shellHook = '' + echo " + Entered the Branch SDK Android development environment. + "; + ''; + packages = [ + pkgs.android-sdk + pkgs.jdk17 # for android build-tools + ]; + }; + }; + } + ); +} diff --git a/gradle.properties b/gradle.properties index c0de72895..e53d4dc80 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ POM_LICENCE_DIST=repo POM_DEVELOPER_ID=branch POM_DEVELOPER_NAME=Branch Metrics -ANDROID_BUILD_SDK_VERSION_MINIMUM=21 +ANDROID_BUILD_SDK_VERSION_MINIMUM=23 ANDROID_BUILD_SDK_VERSION_COMPILE=34 ANDROID_BUILD_TOOLS_VERSION=34.0.0 android.useAndroidX=true