Search Unity

Unknown property 'GradleVersion'

Discussion in 'Android' started by MikeGDev, Jun 25, 2019.

  1. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
    I just upgraded my project from Unity 2017.4 to 2019.1 and I am having problems building now

    I receive the below error

    Any hints to where and how I can fix this?

    CommandInvokationFailure: Gradle build failed.
    S:\Programs\Unity\2019.1.8f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "S:\Programs\Unity\2019.1.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    stderr[

    FAILURE: Build failed with an exception.

    * Where:
    Build file 'S:\Projects\Game\Temp\gradleOut\native_plugins_lib\build.gradle' line: 3

    * What went wrong:
    A problem occurred evaluating project ':native_plugins_lib'.
    > Could not get unknown property 'GradleVersion' for repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 2s
    ]
    stdout[

    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    Rethrow as GradleInvokationException: Gradle build failed
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <1a10f9035b6b403994c99e5b653643c6>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:281)
    UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
    BuildTask:BuildAtPath(BuildTarget, String, BuildOptions) (at Assets/Editor/BuildCreator/BuildTask.cs:53)
    BuildShortcuts:BuildWithOptions(BuildOptions) (at Assets/Editor/BuildShortcuts.cs:124)
    BuildShortcuts:CustomBuildOnly() (at Assets/Editor/BuildShortcuts.cs:16)
     
    oguzhantopsakal likes this.
  2. oguzhantopsakal

    oguzhantopsakal

    Joined:
    Sep 21, 2013
    Posts:
    3
    I have the same issue. Did you find a way to solve it?
     
  3. oguzhantopsakal

    oguzhantopsakal

    Joined:
    Sep 21, 2013
    Posts:
    3
    I had this issue while trying to upgrade an old project to 2019.1.8f1. The android build stops with the following error:

    Could not get unknown property 'GradleVersion' for repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

    You need to go into the 'ProjectMainFolder'/Temp/gradleOut folder. There are several folders in this folder and one of them could be 'native_plugins_lib'. Inside the native_plugins_lib folder, you should find the build.gradle file. The 'GradleVersion' property is in the build.gradle file. I had the followings:

    --------------------------------------------------------------------

    buildscript {
    repositories {
    if (GradleVersion.current() >= GradleVersion.version("4.2")) {
    jcenter()
    google()
    } else {
    jcenter()
    mavenLocal()
    }
    }
    dependencies {
    // use newer version of the plugin for newer unity/gradle versions
    if (GradleVersion.current() < GradleVersion.version("4.0")) {
    classpath 'com.android.tools.build:gradle:2.1.0'
    } else if (GradleVersion.current() < GradleVersion.version("4.2")) {
    classpath 'com.android.tools.build:gradle:2.3.3'
    } else {
    classpath 'com.android.tools.build:gradle:3.0.1'
    }
    }
    }
    apply plugin: 'com.android.library'
    dependencies {
    if (GradleVersion.current() >= GradleVersion.version("4.2"))
    {
    implementation fileTree(dir: 'bin', include: ['*.jar'])
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    }
    else
    {
    compile fileTree(dir: 'bin', include: ['*.jar'])
    compile fileTree(dir: 'libs', include: ['*.jar'])
    }
    }

    --------------------------------------------------------------------

    I removed all lines with 'GradleVersion' and got the following:

    --------------------------------------------------------------------

    buildscript {
    repositories {
    jcenter()
    google()
    }
    dependencies {
    // use newer version of the plugin for newer unity/gradle versions
    classpath 'com.android.tools.build:gradle:3.0.1'
    }
    }
    apply plugin: 'com.android.library'
    dependencies {
    implementation fileTree(dir: 'bin', include: ['*.jar'])
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    }

    --------------------------------------------------------

    You might need to repeat this process to remove 'GradleVersion' from other build.gradle file in other folders in the gradleOut directory.

    Then, inside the gradleOut directory, you can try to run the build from the command prompt by copying the command from the "CommandInvokationFailure: Gradle build failed." error message in the Unity console, in my case:
    "C:\Program Files\Unity\Hub\Editor\2019.1.8f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe" -classpath "C:\Program Files\Unity\Hub\Editor\2019.1.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease" --stacktrace

    Note that I also added '--stacktrace' to the end of the command that I got from the Unity console.

    Hopefully, everything goes fine and you will find your apk in the following folder:
    'ProjectMainFolder'\Temp\gradleOut\build\outputs\apk
     
    russisunni, HunnyMalik and htdreams like this.
  4. fertigo

    fertigo

    Joined:
    Feb 15, 2014
    Posts:
    19
    We are having the same problems in Unity 2018.4.4.

    2018.4.3 works fine so we downgraded to 4.3 waiting for a fix from Unity
     
  5. luvjungle

    luvjungle

    Joined:
    Dec 18, 2017
    Posts:
    58
    same here. 4.3 works fine
     
  6. htdreams

    htdreams

    Joined:
    Mar 29, 2014
    Posts:
    11
    Thanks! I've just updated to Unity 2019.1.11 and was faced with this error out of nowhere... :-D
     
  7. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
    I tried to remove the GradleVersion as you suggested and it worked! Thanks! I also found a new version of the plugin which took care of this as well.
     
  8. Jantmi

    Jantmi

    Joined:
    Mar 13, 2015
    Posts:
    3
    Could you share the new version of the plugin that solved this?
     
  9. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
  10. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Sorry guys! We have posted long back on our forums about this. Unfortunately, I couldn't notice this thread on unity forum.

    Please update these files and it should be good to go.


    In-fact we do have this fix from 2019.17f1 on store but not for older versions as some other plugins might expect gradle 3.4 along with androidx packages - which is only available from 2019.1.7.

    However, as long as there is no such dependency with the other plugins you are using, you can still update the above files and stay on your existing version.

    Thanks,
    VB Team
     
  11. anthodb

    anthodb

    Joined:
    Sep 6, 2012
    Posts:
    20
    Maybe this could help someone later.. I spent almost three hours on a bug like this one (gradleout unknown property). Now, it seems stupid, but I had some commented code in my baseTemplate.gradle and mainTemplate.gradle that were "overriden" by Unity during build.. Those properties were overriden but still "commented".. so not working.. Removing all comments from templates fixed the issues.