Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Gradle Version Error when building

Discussion in 'Android' started by CalaveraX, Apr 26, 2022.

  1. CalaveraX

    CalaveraX

    Joined:
    Jul 11, 2013
    Posts:
    143
    Hello guys!

    Im trying to build my project after doing a unity migration from unity 2018 to unity 2020 and im having this compilation error:


    FAILURE: Build failed with an exception.

    * Where:
    Build file 'D:\Unity Projects\Rome_Migration\GrowRome_IAPS_Current\Temp\gradleOut\unityLibrary\build.gradle' line: 58

    * What went wrong:
    A problem occurred evaluating project ':unityLibrary'.
    > Failed to apply plugin [id 'com.android.internal.version-check']
    > Minimum supported Gradle version is 6.7.1. Current version is 6.1.1. If using the gradle wrapper, try editing the distributionUrl in D:\Unity Projects\Rome_Migration\GrowRome_IAPS_Current\Temp\gradleOut\gradle\wrapper\gradle-wrapper.properties to gradle-6.7.1-all.zip

    My Gradle File looks as this: (And line 58 makes reference to apply plugin: 'com.android.library')


    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    buildscript {
    repositories {
    google()
    mavenCentral()
    }

    dependencies {
    classpath 'com.android.tools.build:gradle:4.2.2'
    }
    }

    allprojects {
    repositories {
    google()
    mavenCentral()
    maven {
    url "https://repo.spring.io/release"
    }
    maven {
    url "https://repository.jboss.org/maven2"
    }

    flatDir {
    dirs 'libs'
    }
    }
    }

    // Android Resolver Repos Start
    ([rootProject] + (rootProject.subprojects as List)).each { project ->
    project.repositories {
    def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
    maven {
    url "https://maven.google.com"
    }
    maven {
    url "https://maven.google.com" // Assets/Chartboost/Editor/ChartboostDependencies.xml:12
    }
    maven {
    url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22, Assets/Firebase/Editor/RemoteConfigDependencies.xml:20
    }
    maven {
    url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
    }

    maven {
    url (unityProjectPath + "/Packages/com.google.play.games/Editor/m2repository") // Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
    }
    maven {
    url "https://google.bintray.com/mobile-ads-adapters-android" // Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml:18
    }
    mavenLocal()
    mavenCentral()
    }
    }
    // Android Resolver Repos End
    apply plugin: 'com.android.library'

    configurations {
    compile.exclude group: 'com.google.zxing'
    }

    dependencies {
    implementation fileTree(dir: 'bin', include: ['*.jar'])
    //implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation fileTree(dir: 'libs', include: ['*.jar','*/Plugins/Android/*.aar'])
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.android.installreferrer:installreferrer:1.0'
    // Android Resolver Dependencies Start
    implementation 'com.android.support:appcompat-v7:27.1.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:6
    //implementation 'com.android.support:support-v4:27.1.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:5
    implementation 'com.android.support:support-v4:28.0.0+' // Assets/UTNotifications/Editor/UTNotificationsAndroidMinDependencies.xml:7
    implementation 'com.google.ads.mediation:unity-adapter-only:3.6.0.0' // Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml:18
    implementation 'com.google.android.gms:play-services-ads:20.2.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
    implementation 'com.google.android.gms:play-services-ads-identifier:15.0.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:4
    // implementation 'com.google.android.gms:play-services-base:15.0.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:3
    implementation 'com.google.android.gms:play-services-base:18.0.1' // Assets/Firebase/Editor/AppDependencies.xml:17
    implementation 'com.google.firebase:firebase-analytics:20.1.2' // Assets/Firebase/Editor/RemoteConfigDependencies.xml:15
    implementation 'com.google.firebase:firebase-analytics-unity:8.9.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    implementation 'com.google.firebase:firebase-app-unity:8.9.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    implementation 'com.google.firebase:firebase-common:20.1.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    implementation 'com.google.firebase:firebase-config:21.0.2' // Assets/Firebase/Editor/RemoteConfigDependencies.xml:13
    implementation 'com.google.firebase:firebase-config-unity:8.9.0' // Assets/Firebase/Editor/RemoteConfigDependencies.xml:20
    implementation 'com.google.games:gpgs-plugin-support:0.11.01' // Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
    // Android Resolver Dependencies End
    **DEPS**
    }

    // Android Resolver Exclusions Start
    android {
    packagingOptions {
    exclude ('/lib/armeabi/*' + '*')
    exclude ('/lib/armeabi-v7a/*' + '*')
    exclude ('/lib/mips/*' + '*')
    exclude ('/lib/mips64/*' + '*')
    exclude ('/lib/x86/*' + '*')
    exclude ('/lib/x86_64/*' + '*')
    }
    }
    // Android Resolver Exclusions End
    android {
    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    defaultConfig {
    consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    minSdkVersion **MINSDKVERSION**
    targetSdkVersion **TARGETSDKVERSION**

    ndk {
    abiFilters **ABIFILTERS**
    }
    versionCode **VERSIONCODE**
    versionName '**VERSIONNAME**'
    multiDexEnabled true
    }

    lintOptions {
    abortOnError false
    }

    aaptOptions {
    noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

    **SIGN**
    buildTypes {
    debug {
    minifyEnabled **MINIFY_DEBUG**

    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    jniDebuggable true
    }
    release {
    minifyEnabled **MINIFY_RELEASE**

    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    **SIGNCONFIG**
    }
    }
    **PACKAGING_OPTIONS**

    }


    **SOURCE_BUILD_SETUP**
     
    Last edited: Apr 26, 2022
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,682
    Do you have gradle templates set, if so, maybe there out of date with Unity 2020?
     
  3. CalaveraX

    CalaveraX

    Joined:
    Jul 11, 2013
    Posts:
    143
    Yes, i have the custom Main Gradle Template enabled on settings, is the one i have attached on the post

    In the template i have setted graddle to 4.2.2 wich is suposed to be gradle version 6.7.1+ its weird that is telling me that im using a previous version. shoul i update it somehow ?
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,682
    4.2.2 is Android Gradle Plugin version, while the error is complaining about gradle version.

    Try recreating the template. Here's a page explaining the compatibility - https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

    Here's the page regarding what gradle versions are used by specific Unity versions - https://docs.unity3d.com/Manual/android-gradle-overview.html

    In other words, unless you override the gradle version used by Unity, you can only use Android Gradle Plugin Version [4.0.0, 4.1.0).
     
    ilmario likes this.
  5. CalaveraX

    CalaveraX

    Joined:
    Jul 11, 2013
    Posts:
    143

    i have recreated the template by deleting it, enabling and force resolve in external dependency manager, but now i have other errors its seems to not being able to find some libraries that the resolver has setted in the gradle:


    * What went wrong:
    Could not determine the dependencies of task ':unityLibrary:compileReleaseAidl'.
    > Could not resolve all task dependencies for configuration ':unityLibrary:releaseCompileClasspath'.
    > Could not resolve com.google.ads.mediation:unity-adapter-only:3.6.0.0.
    Required by:
    project :unityLibrary
    > Skipped due to earlier error
    > Could not resolve com.google.games:gpgs-plugin-support:0.11.01.
    Required by:
    project :unityLibrary


    the new Manifest is this:


    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

    // Android Resolver Repos Start
    ([rootProject] + (rootProject.subprojects as List)).each { project ->
    project.repositories {
    def unityProjectPath = $/file:///D:/Unity Projects/Rome_Migration/GrowRome_IAPS_Current/$.replace("\\", "/")
    maven {
    url "https://maven.google.com"
    }
    maven {
    url "https://maven.google.com" // Assets/Chartboost/Editor/ChartboostDependencies.xml:12
    }
    maven {
    url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22, Assets/Firebase/Editor/RemoteConfigDependencies.xml:20
    }
    maven {
    url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
    }
    maven {
    url "https://jcenter.bintray.com/" // Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml:18
    }
    maven {
    url (unityProjectPath + "/Packages/com.google.play.games/Editor/m2repository") // Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
    }
    maven {
    url "https://google.bintray.com/mobile-ads-adapters-android" // Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml:18
    }
    mavenLocal()
    mavenCentral()
    }
    }
    // Android Resolver Repos End
    apply plugin: 'com.android.library'


    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    // Android Resolver Dependencies Start
    implementation 'com.android.support:appcompat-v7:27.1.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:6
    // implementation 'com.android.support:support-v4:27.1.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:5
    implementation 'com.android.support:support-v4:28.0.0+' // Assets/UTNotifications/Editor/UTNotificationsAndroidMinDependencies.xml:7
    implementation 'com.google.ads.mediation:unity-adapter-only:3.6.0.0' // Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml:18
    implementation 'com.google.android.gms:play-services-ads:20.2.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
    implementation 'com.google.android.gms:play-services-ads-identifier:15.0.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:4
    // implementation 'com.google.android.gms:play-services-base:15.0.1' // Assets/Chartboost/Editor/ChartboostDependencies.xml:3
    implementation 'com.google.android.gms:play-services-base:18.0.1' // Assets/Firebase/Editor/AppDependencies.xml:17
    implementation 'com.google.firebase:firebase-analytics:20.1.2' // Assets/Firebase/Editor/RemoteConfigDependencies.xml:15
    implementation 'com.google.firebase:firebase-analytics-unity:8.9.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
    implementation 'com.google.firebase:firebase-app-unity:8.9.0' // Assets/Firebase/Editor/AppDependencies.xml:22
    implementation 'com.google.firebase:firebase-common:20.1.0' // Assets/Firebase/Editor/AppDependencies.xml:13
    implementation 'com.google.firebase:firebase-config:21.0.2' // Assets/Firebase/Editor/RemoteConfigDependencies.xml:13
    implementation 'com.google.firebase:firebase-config-unity:8.9.0' // Assets/Firebase/Editor/RemoteConfigDependencies.xml:20
    implementation 'com.google.games:gpgs-plugin-support:0.11.01' // Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
    // Android Resolver Dependencies End
    implementation(name: 'billing-3.0.3', ext:'aar')
    implementation(name: 'common', ext:'aar')
    implementation(name: 'flurry-analytics', ext:'aar')
    implementation(name: 'googlemobileads-unity', ext:'aar')
    implementation(name: 'UnityAds', ext:'aar')
    implementation(name: 'UnityAdsAndroidPlugin', ext:'aar')
    implementation(name: 'UnityChannel', ext:'aar')
    implementation(name: 'utnotifications', ext:'aar')
    implementation project('FirebaseApp.androidlib')
    implementation project('GoogleMobileAdsPlugin.androidlib')
    implementation project('GooglePlayGamesManifest.androidlib')
    }

    // Android Resolver Exclusions Start
    android {
    packagingOptions {
    exclude ('/lib/armeabi/*' + '*')
    exclude ('/lib/armeabi-v7a/*' + '*')
    exclude ('/lib/mips/*' + '*')
    exclude ('/lib/mips64/*' + '*')
    exclude ('/lib/x86/*' + '*')
    exclude ('/lib/x86_64/*' + '*')
    }
    }
    // Android Resolver Exclusions End
    android {
    compileSdkVersion 30
    buildToolsVersion '30.0.2'

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
    minSdkVersion 21
    targetSdkVersion 30
    ndk {
    abiFilters 'arm64-v8a'
    }
    versionCode 431
    versionName '1.14.4'
    consumerProguardFiles 'proguard-unity.txt'
    }

    lintOptions {
    abortOnError false
    }

    aaptOptions {
    noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

    packagingOptions {
    doNotStrip '*/arm64-v8a/*.so'
    }
    }
     
  6. CalaveraX

    CalaveraX

    Joined:
    Jul 11, 2013
    Posts:
    143
    and only to check if commenting those two dependencies it could build i get this errors:


    * What went wrong:
    Could not determine the dependencies of task ':launcher:processReleaseResources'.
    > Could not resolve all task dependencies for configuration ':launcher:releaseRuntimeClasspath'.
    > Could not resolve com.google.android.gms:play-services-ads-base:[20.2.0].
    Required by:
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:20.2.0
    project :launcher > project :unityLibrary > com.google.android.gms:play-services-ads:20.2.0 > com.google.android.gms:play-services-ads-lite:20.2.0
    > Failed to list versions for com.google.android.gms:play-services-ads-base.
    > Unable to load Maven meta-data from https://google.bintray.com/mobile-a...gms/play-services-ads-base/maven-metadata.xml.
    > Could not get resource 'https://google.bintray.com/mobile-a...gms/play-services-ads-base/maven-metadata.xml'.
    > Could not GET 'https://google.bintray.com/mobile-a...gms/play-services-ads-base/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,682
    Sorry, I am not familiar with Google Ads dependencies, try google'ing - since it's not Unity specific issue.
     
  8. AliJomeiy

    AliJomeiy

    Joined:
    Feb 6, 2018
    Posts:
    3
    Hey there could any one find a suitable answer, I have same issue.
     
  9. EyeDev44

    EyeDev44

    Joined:
    Apr 8, 2017
    Posts:
    141
    Same after update to 2022.3 LTS.
     
    mericsafacan likes this.