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

Bug Android: Build Failed. Failed to apply plugin [id 'com.android.internal.version-check']

Discussion in 'Editor & General Support' started by JustenC, Sep 28, 2023.

  1. JustenC

    JustenC

    Joined:
    Nov 4, 2015
    Posts:
    2
    Hello,

    I'm trying to create an android build for my application, but I keep getting this error.


    A problem occurred evaluating project ':launcher'.
    > Failed to apply plugin [id 'com.android.internal.version-check']
    > Could not create plugin of type 'VersionCheckPlugin'.
    > Could not initialize class com.android.build.gradle.internal.plugins.VersionCheckPlugin


    General information:
    • Unity 2021.3.24f1
    • Gradle 6.1.1
    • Gradle Plugin 4.0.1
    • Java 1.8
    • Min Build Target = API Level 22
    Things I've tried:
    • Reverting back to an older commit
    • Completely uninstalling Unity, the Repo, and all related files and reinstalling
    • Changing jCenter() in gradle.build to mavenCentral()
    • Upgrading to Gradle 7.2 via Android Studio
    I can't seem to find anything on google regarding this library or class and it doesn't seem like there are very many other people that have had this particular bug. I'm guessing that I'm probably using a deprecated library or something, but I haven't found any information regarding that or what version I should be using. I was able to create a build a few days ago as well, but now this keeps happening.

    I have been searching for many hours now so any help would be greatly appreciated.

    Thanks

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

    Relevant Files and Information (Probably. Please let me know if other files/information is needed):

    Library\Bee\Android\Prj\Mono2x\Gradle\launcher\build.gradle

    apply plugin: 'com.android.application'
    dependencies {
    implementation project(':unityLibrary')
    }
    android {
    compileSdkVersion 30
    buildToolsVersion '30.0.2'
    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
    minSdkVersion 22
    targetSdkVersion 30
    applicationId 'com.UnityTechnologies.com.unity.template.urpblank'
    ndk {
    abiFilters 'armeabi-v7a'
    }
    versionCode 1
    versionName '0.1.0'
    }
    aaptOptions {
    noCompress = ['.unity3d', '.ress', '.resource', '.obb', '.bundle', '.unityexp'] + unityStreamingAssets.tokenize(', ')
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }
    lintOptions {
    abortOnError false
    }
    buildTypes {
    debug {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt')
    signingConfig signingConfigs.debug
    jniDebuggable true
    }
    release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt')
    signingConfig signingConfigs.debug
    }
    }
    packagingOptions {
    doNotStrip '*/armeabi-v7a/*.so'
    }
    bundle {
    language {
    enableSplit = false
    }
    density {
    enableSplit = false
    }
    abi {
    enableSplit = true
    }
    }
    }


    Library\Bee\Android\Prj\Mono2x\Gradle\build.gradle

    allprojects {
    buildscript {
    repositories {
    google()
    jcenter()
    }
    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'

    }
    }
    repositories {
    google()
    jcenter()
    flatDir {
    dirs "${project(':unityLibrary').projectDir}/libs"
    }
    }
    }
    task clean(type: Delete) {
    delete rootProject.buildDir
    }


    Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\build.gradle

    apply plugin: 'com.android.library'
    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    }
    android {
    compileSdkVersion 30
    buildToolsVersion '30.0.2'
    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
    minSdkVersion 22
    targetSdkVersion 30
    ndk {
    abiFilters 'armeabi-v7a'
    }
    versionCode 1
    versionName '0.1.0'
    consumerProguardFiles 'proguard-unity.txt'
    }
    lintOptions {
    abortOnError false
    }
    aaptOptions {
    noCompress = ['.unity3d', '.ress', '.resource', '.obb', '.bundle', '.unityexp'] + unityStreamingAssets.tokenize(', ')
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }
    packagingOptions {
    doNotStrip '*/armeabi-v7a/*.so'
    }
    }


    gradle.properties

    org.gradle.jvmargs=-Xmx4096M
    org.gradle.parallel=true
    android.enableR8=false
    unityStreamingAssets=
    unityTemplateVersion=3


    gradle-wrapper

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip


    The Full Error Message

    CommandInvokationFailure: Gradle build failed.
    C:\Program Files\Unity\Hub\Editor\2021.3.24f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.3.24f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    stderr[

    FAILURE: Build failed with an exception.*

    Where:
    Build file 'C:\Users\[redacted]\Documents\GitRepos\[Project-Name]\Library\Bee\Android\Prj\Mono2x\Gradle\launcher\build.gradle' line: 1

    * What went wrong:
    A problem occurred evaluating project ':launcher'.
    > Failed to apply plugin [id 'com.android.internal.version-check']
    > Could not create plugin of type 'VersionCheckPlugin'.
    > Could not initialize class com.android.build.gradle.internal.plugins.VersionCheckPlugin

    * 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 [URL='https://help.gradle.org/']https://help.gradle.org[/URL]BUILD FAILED in 959ms
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    ]
    stdout[]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    Rethrow as GradleInvokationException: Gradle build failed
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <fa6b86c947e14a6a903c64a6b203942b>: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 <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <fa6b86c947e14a6a903c64a6b203942b>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, 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 <e3d2e3f6a525465bbf8c67432a3cb6ef>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    37,149
    Here's more reading and things to try:

    How to troubleshoot build failures:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

    Android build not building:

    Recently (circa July 2022) there have been reports of Unity's installer failing to install the Android Tools.

    https://forum.unity.com/threads/cant-build-for-android.1306098/

    Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022 (edited on August 23, 2023 to include Android SDK 33...):

    https://forum.unity.com/threads/aab...y-2021-3-8-with-jdk-1-8.1322211/#post-8551193

    Android Gradle errors and other related stuff:

    https://forum.unity.com/threads/unity-gradle-bug-please-help.1368018/#post-8625789