For Unity 2022.2 and newer

  1. If you do not already have custom Gradle files in your project:

    Under Player > Android tab > Publishing Settings > Build, use the checkboxes to select Custom Main Gradle Template, Custom Base Gradle Template, and Custom Gradle Properties Template.

    This will automatically generate the files mainTemplate.gradle, gradleTemplate.properties, and settingsTemplate.gradle, respectively, in the Assets/Plugins/Android directory.

    project settings gradle 2022
    Project settings in Unity 2022.2 and newer
  2. For mainTemplate.gradle, add 'implementation 'com.strivr.strivr.sdk:strivr.sdk:1.0.0.0'' in the dependencies section.

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.strivr.strivr.sdk:strivr.sdk:1.0.0.0'
    **DEPS**}

    The entire file should look like this:

    apply plugin: 'com.android.library'
    **APPLY_PLUGINS**
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.strivr.strivr.sdk:strivr.sdk:1.0.0.0'
    **DEPS**}
    
    android {
        ndkPath "**NDKPATH**"
    
        compileSdkVersion **APIVERSION**
        buildToolsVersion '**BUILDTOOLS**'
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_11
            targetCompatibility JavaVersion.VERSION_11
        }
    
        defaultConfig {
            minSdkVersion **MINSDKVERSION**
            targetSdkVersion **TARGETSDKVERSION**
            ndk {
                abiFilters **ABIFILTERS**
            }
            versionCode **VERSIONCODE**
            versionName '**VERSIONNAME**'
            consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
        }
    
        lintOptions {
            abortOnError false
        }
    
        aaptOptions {
            noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
            ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
        }**PACKAGING_OPTIONS**
    }
    **IL_CPP_BUILD_SETUP**
    **SOURCE_BUILD_SETUP**
    **EXTERNAL_SOURCES**
  3. For gradleTemplate.properties, add 'android.useAndroidX=true' in the ADDITIONAL_PROPERTIES section, so that your file looks like this:

    org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
    org.gradle.parallel=true
    unityStreamingAssets=**STREAMING_ASSETS**
    **ADDITIONAL_PROPERTIES**
    android.useAndroidX=true
  4. For settingsTemplate.gradle, add 'maven { url 'https://pkgs.dev.azure.com/strivr/SDK/_packaging/StrivrPublicFeed/maven/v1' }' in both repositories sections, so that your file looks like this:

    pluginManagement {
        repositories {
            **ARTIFACTORYREPOSITORY**
            gradlePluginPortal()
            google()
            mavenCentral()
            maven {
                url 'https://pkgs.dev.azure.com/strivr/SDK/_packaging/StrivrPublicFeed/maven/v1'
            }
        }
    }
    
    include ':launcher', ':unityLibrary'
    **INCLUDES**
    
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
        repositories {
            **ARTIFACTORYREPOSITORY**
            google()
            mavenCentral()
            maven {
                url 'https://pkgs.dev.azure.com/strivr/SDK/_packaging/StrivrPublicFeed/maven/v1'
            }
            flatDir {
                dirs "${project(':unityLibrary').projectDir}/libs"
            }
        }
    }