Fixed: Could not resolve all files for configuration ‘:launcher:releaseRuntimeClasspath’.

This is done on Unity 2022.3.28f1 and I encountered this issue when trying to export the app after installing Ads Mediation from Unity

First, go to File >> Build Setting >> Player Settings >> Enable Custom Base Gradle Template and Custom Gradle Settings Template

Now, go to Assets >> Plugins >> Android, open settingsTemplate.gradle. It looks something like this

pluginManagement {
    repositories {
        **ARTIFACTORYREPOSITORY**
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

include ':launcher', ':unityLibrary'
**INCLUDES**

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        **ARTIFACTORYREPOSITORY**
        google()
        mavenCentral()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

Now, remove the dependencyResolutionManagement function, save and close the file.

Next, go to Assets >> Plugins >> Android, open baseProjectTemplate. For me, initially, it looks like this

plugins {
    // 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
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
    **BUILD_SCRIPT_DEPS**
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Now, add this function between “plugins” and “task clean”:

allprojects {
    repositories {
        **ARTIFACTORYREPOSITORY**
        google()
        mavenCentral()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

Click to download the code

Save and close, and try to export the app again. Good luck!

Note: the answer is based on the answer of 256p on Github, with modifications for a newer version of Unity.


Discover more from Science Comics

Subscribe to get the latest posts sent to your email.

Leave a Reply

error: Content is protected !!