For Unity 2020.3-2022.1

  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, baseProjectTemplate.gradle, and gradleTemplate.properties, respectively, in the Assets/Plugins/Android directory.

    project settings unity2020
    Project Settings in Unity 2020-2022.1
  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**}

    Your 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 {
        compileSdkVersion **APIVERSION**
        buildToolsVersion '**BUILDTOOLS**'
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    
        defaultConfig {
            minSdkVersion **MINSDKVERSION**
            targetSdkVersion **TARGETSDKVERSION**
            ndk {
                abiFilters **ABIFILTERS**
            }
            versionCode **VERSIONCODE**
            versionName '**VERSIONNAME**'
            consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
        }
    
        lintOptions {
            abortOnError false
        }
    
        aaptOptions {
            noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
            ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
        }**PACKAGING_OPTIONS**
    }**REPOSITORIES**
    **IL_CPP_BUILD_SETUP**
    **SOURCE_BUILD_SETUP**
    **EXTERNAL_SOURCES**
  3. For baseProjectTemplate.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:

    allprojects {
        buildscript {
            repositories {**ARTIFACTORYREPOSITORY**
                google()
                jcenter()
                maven {
                    url 'https://pkgs.dev.azure.com/strivr/SDK/_packaging/StrivrPublicFeed/maven/v1'
                }
            }
    
            dependencies {
                // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
                // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
                // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
                // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
                classpath 'com.android.tools.build:gradle:4.0.1'
                **BUILD_SCRIPT_DEPS**
            }
        }
    
        repositories {**ARTIFACTORYREPOSITORY**
            google()
            jcenter()
            maven {
                url 'https://pkgs.dev.azure.com/strivr/SDK/_packaging/StrivrPublicFeed/maven/v1'
            }
            flatDir {
                dirs "${project(':unityLibrary').projectDir}/libs"
            }
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
  4. 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
    android.enableR8=**MINIFY_WITH_R_EIGHT**
    unityStreamingAssets=.unity3d**STREAMING_ASSETS**
    **ADDITIONAL_PROPERTIES**
    android.useAndroidX=true