Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Gradle Prewarm Failed in Unity 2018.3.3f1

Discussion in 'Android' started by tonycsharks, Jan 28, 2019.

  1. tonycsharks

    tonycsharks

    Joined:
    Dec 31, 2015
    Posts:
    25
    While trying to build my project its showing an error like this:



    Code (CSharp):
    1. CommandWithNoStdoutInvokationFailure: Gradle prewarm failed.
    2. UnityEditor.Android.Command.RunWithShellExecute (System.String command, System.String args, System.String workingdir, System.String errorMsg) (at <492d67763d4d482e8616a9848b18ccab>:0)
    3. UnityEditor.Android.AndroidJavaTools.RunJavaWithShellExecute (System.String args, System.String workingdir, System.String error) (at <492d67763d4d482e8616a9848b18ccab>:0)
    4. UnityEditor.Android.GradleWrapper.WarmupGradle (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String baseCommand) (at <492d67763d4d482e8616a9848b18ccab>:0)
    5. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <492d67763d4d482e8616a9848b18ccab>:0)
    6. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <492d67763d4d482e8616a9848b18ccab>:0)
    7. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <492d67763d4d482e8616a9848b18ccab>:0)
    8. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    9.  
    This error was also there in the previous unity version Unity 2018.3.2f1. And the release notes for the Unity 2018.3.3f1 (https://unity3d.com/unity/whats-new/2018.3.3) showed as

    Android: Fixed gradle warmup errors when project root includes gradle files. (1109183)




    I was having this issue from the last few unity versions and I thought this issue will be fixed in this version too. I have enabled MultiDex support as I was having the DEX 64K limit. Here is my custom modified mainTemplate.gradle file which has been edited based on the suggestions from various posts in Unity answers as well as Unity forums. I don't know if this is correct or not as I'm not an expert in gradle files. So if there are any other errors in my custom modified mainTemplate.gradle, please let me know.

    Code (CSharp):
    1. buildscript {
    2.     repositories {
    3.         google()
    4.         jcenter()
    5.     }
    6.  
    7.     dependencies {
    8.         classpath 'com.android.tools.build:gradle:3.2.0'
    9.         compile 'com.android.support:multidex:''
    10. **BUILD_SCRIPT_DEPS**}
    11. }
    12.  
    13. allprojects {
    14.    repositories {
    15.        google()
    16.        jcenter()
    17.        flatDir {
    18.            dirs 'libs'
    19.        }
    20.    }
    21. }
    22.  
    23. apply plugin: 'com.android.application'
    24. **APPLY_PLUGINS**
    25.  
    26. dependencies {
    27.    implementation fileTree(dir: 'libs', include: ['*.jar'])
    28. **DEPS**}
    29.  
    30. android {
    31.    compileSdkVersion **APIVERSION**
    32.    buildToolsVersion '**BUILDTOOLS**'
    33.  
    34.    compileOptions {
    35.        sourceCompatibility JavaVersion.VERSION_1_8
    36.        targetCompatibility JavaVersion.VERSION_1_8
    37.    }
    38.  
    39.    defaultConfig {
    40.        minSdkVersion **MINSDKVERSION**
    41.        targetSdkVersion **TARGETSDKVERSION**
    42.        applicationId '**APPLICATIONID**'
    43.        multiDexEnabled true
    44.        ndk {
    45.            abiFilters **ABIFILTERS**
    46.        }
    47.        versionCode **VERSIONCODE**
    48.        versionName '**VERSIONNAME**'
    49.    }
    50.  
    51.    lintOptions {
    52.        abortOnError false
    53.    }
    54.  
    55.    aaptOptions {
    56.        noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
    57.    }**SIGN**
    58.  
    59.    buildTypes {
    60.        debug {
    61.            minifyEnabled **MINIFY_DEBUG**
    62.            useProguard **PROGUARD_DEBUG**
    63.            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    64.            jniDebuggable true
    65.            multiDexEnabled true
    66.        }
    67.        release {
    68.            minifyEnabled **MINIFY_RELEASE**
    69.            useProguard **PROGUARD_RELEASE**
    70.            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
    71.            multiDexEnabled true
    72.        }
    73.    }**PACKAGING_OPTIONS****SPLITS**
    74. **BUILT_APK_LOCATION**
    75.    bundle {
    76.        language {
    77.            enableSplit = false
    78.        }
    79.        density {
    80.            enableSplit = false
    81.        }
    82.        abi {
    83.            enableSplit = true
    84.        }
    85.    }
    86. }**SPLITS_VERSION_CODE****REPOSITORIES****SOURCE_BUILD_SETUP**
    87.  
    I have also added
    <application android:name="android.support.multidex.MultiDexApplication">
    in my Android Manifest to enable the multidex support. and I hope what I did is correct. Is this issue due to the old gradle version in my Unity? If yes, how to update the gradle version in Unity to the latest version so that this issue can be resolved.
    So can someone please help me how to fix this issue of gradle prewarm error in Unity 2018.3.3f1? I'm struggling to fix this issue since the past 1 month. still the issue is not solved. So I need the help of someone who knows more about this error.
     
  2. Metlov

    Metlov

    Joined:
    Jan 23, 2017
    Posts:
    1
    Still reproduces for me on 3.3
     
  3. zz_unity

    zz_unity

    Joined:
    Dec 11, 2018
    Posts:
    1
    The same for me
     
  4. Garrettec

    Garrettec

    Joined:
    Nov 26, 2012
    Posts:
    76
    Also have this issue, Unity definitely need to make some gradle / multidex instruction in documentation about modifying mainTemplate...
     
  5. EvaMuller

    EvaMuller

    Joined:
    Aug 15, 2017
    Posts:
    1
  6. sunxdc15

    sunxdc15

    Joined:
    Jan 2, 2014
    Posts:
    7
    the same for me, 2018.3.3f1
     
  7. gamepower7

    gamepower7

    Joined:
    May 16, 2017
    Posts:
    24
    same for unity 2018.3.4f1
     
  8. schauer93

    schauer93

    Joined:
    Jan 8, 2019
    Posts:
    3
    you need to save your current mainTemplate.gradle, remove it and generate a new one (re-enable Publishing Settings / Custom Template)
     
  9. alan_motionlab

    alan_motionlab

    Joined:
    Nov 27, 2014
    Posts:
    90
    Not sure if its causing your problem or not, but it looks like you have two '' marks after the multidex inclusion of line 10 of your build.gradle. Not sure if that's intentional or not.
     
  10. alan_motionlab

    alan_motionlab

    Joined:
    Nov 27, 2014
    Posts:
    90
    I'm having this issue as well though - your changes or with the single quotes makes no difference with single or multidex builds. I'm using 2018.3.4f1 and still has the issue.
     
  11. adeelbabu

    adeelbabu

    Joined:
    May 24, 2017
    Posts:
    2
    Solved !!
    Updating Android Studio to Latest version.
     
  12. murtazaali

    murtazaali

    Joined:
    Sep 25, 2017
    Posts:
    2
    Basically where is issue
     
  13. Shmoji

    Shmoji

    Joined:
    Nov 16, 2017
    Posts:
    14
    I struggled and struggled with this issue and this is what finally helped solve the error for me