Search Unity

Gradle error

Discussion in 'Android' started by rogerdv, Apr 17, 2019.

  1. rogerdv

    rogerdv

    Joined:
    Jul 16, 2012
    Posts:
    36
    Im getting this error when trying to buld my app:

    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. A:\Roger\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "A:\Roger\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    3.  
    4. stderr[
    5.  
    6. FAILURE: Build failed with an exception.
    7.  
    8. * What went wrong:
    9. Could not resolve all files for configuration ':_internal_aapt2_binary'.
    10. > Could not resolve com.android.tools.build:aapt2:3.2.0-4818971.
    11.   Required by:
    12.       project :
    13.    > Could not resolve com.android.tools.build:aapt2:3.2.0-4818971.
    14.       > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom'.
    15.          > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom'.
    16.             > Connect to dl.google.com:443 [dl.google.com/172.217.8.110] failed: Connection timed out: connect
    17.    > Could not resolve com.android.tools.build:aapt2:3.2.0-4818971.
    18.       > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom'.
    19.          > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom'.
    20.             > jcenter.bintray.com
    21.  
    22. * Try:
    23. 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.
    24.  
    25. * Get more help at https://help.gradle.org
    26.  
    27. BUILD FAILED in 38s
    28. ]
    29. stdout[
    30. :checkReleaseClasspath
    31. :preBuild UP-TO-DATE
    32. :preReleaseBuild
    33. :compileReleaseAidl NO-SOURCE
    34. :compileReleaseRenderscript
    35. :checkReleaseManifest
    36. :generateReleaseBuildConfig
    37. :prepareLintJar
    38. :mainApkListPersistenceRelease
    39. :generateReleaseResValues
    40. :generateReleaseResources
    41. :mergeReleaseResources FAILED
    42. 9 actionable tasks: 9 executed
    43. ]
    44. exit code: 1
    45. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <177bc8179be6497489c4b5b319f290d7>:0)
    46. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <177bc8179be6497489c4b5b319f290d7>:0)
    47. UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <177bc8179be6497489c4b5b319f290d7>:0)
    48. UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <177bc8179be6497489c4b5b319f290d7>:0)
    49. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <177bc8179be6497489c4b5b319f290d7>:0)
    50. Rethrow as GradleInvokationException: Gradle build failed
    51. UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <177bc8179be6497489c4b5b319f290d7>:0)
    52. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <177bc8179be6497489c4b5b319f290d7>:0)
    53. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <177bc8179be6497489c4b5b319f290d7>:0)
    54. Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    55. UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <177bc8179be6497489c4b5b319f290d7>:0)
    56. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <177bc8179be6497489c4b5b319f290d7>:0)
    57. 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 <177bc8179be6497489c4b5b319f290d7>:0)
    58. UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <177bc8179be6497489c4b5b319f290d7>:0)
    59. 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)
    60. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    61.  
    I guess that Unity is trying to download gradle and fails, because my PC is disconnected. Until 2018.3 I solved this using internal compiler, but now it is deprecated. How can I installa working gradle in an offline PC?
     
    prashantsavalia likes this.
  2. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    95
    Show your gradle template
     
  3. rogerdv

    rogerdv

    Joined:
    Jul 16, 2012
    Posts:
    36
    Where can I find it?
     
  4. rogerdv

    rogerdv

    Joined:
    Jul 16, 2012
    Posts:
    36
    I think I found them:
    this is libTemplate.gradle

    Code (CSharp):
    1.  
    2. buildscript {
    3.     repositories {
    4.         google()
    5.         jcenter()
    6.     }
    7.     dependencies {
    8.         classpath 'com.android.tools.build:gradle:3.2.0'
    9.     }
    10. }
    11.  
    12. apply plugin: 'android-library'
    13.  
    14. dependencies {
    15.     implementation fileTree(dir: 'bin', include: ['*.jar'])
    16.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    17. }
    18.  
    19. android {
    20.     sourceSets {
    21.         main {
    22.             manifest.srcFile 'AndroidManifest.xml'
    23.             //java.srcDirs = ['src']
    24.             res.srcDirs = ['res']
    25.             assets.srcDirs = ['assets']
    26.             jniLibs.srcDirs = ['libs']
    27.         }
    28.     }
    29.  
    30.     compileSdkVersion **APIVERSION**
    31.     buildToolsVersion '**BUILDTOOLS**'
    32.     defaultConfig {
    33.         targetSdkVersion **LIBSDKTARGET**
    34.     }
    35.  
    36.     lintOptions {
    37.         abortOnError false
    38.     }
    39. }
    40.  
    41.  
    and thi sis mainTemplate.gradle
    Code (CSharp):
    1. // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    2.  
    3. buildscript {
    4.     repositories {
    5.         google()
    6.         jcenter()
    7.     }
    8.  
    9.     dependencies {
    10.         classpath 'com.android.tools.build:gradle:3.2.0'
    11. **BUILD_SCRIPT_DEPS**}
    12. }
    13.  
    14. allprojects {
    15.     repositories {
    16.         google()
    17.         jcenter()
    18.         flatDir {
    19.             dirs 'libs'
    20.         }
    21.     }
    22. }
    23.  
    24. apply plugin: 'com.android.application'
    25. **APPLY_PLUGINS**
    26.  
    27. dependencies {
    28.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    29. **DEPS**}
    30.  
    31. android {
    32.     compileSdkVersion **APIVERSION**
    33.     buildToolsVersion '**BUILDTOOLS**'
    34.  
    35.     compileOptions {
    36.         sourceCompatibility JavaVersion.VERSION_1_8
    37.         targetCompatibility JavaVersion.VERSION_1_8
    38.     }
    39.  
    40.     defaultConfig {
    41.         minSdkVersion **MINSDKVERSION**
    42.         targetSdkVersion **TARGETSDKVERSION**
    43.         applicationId '**APPLICATIONID**'
    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.         ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    58.     }**SIGN**
    59.  
    60.     buildTypes {
    61.         debug {
    62.             minifyEnabled **MINIFY_DEBUG**
    63.             useProguard **PROGUARD_DEBUG**
    64.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
    65.             jniDebuggable 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.         }
    72.     }**PACKAGING_OPTIONS****SPLITS**
    73. **BUILT_APK_LOCATION**
    74. **EXTERNAL_SOURCES**
    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.  
     
  5. DragonGyke

    DragonGyke

    Joined:
    Feb 1, 2018
    Posts:
    2
    Hey Rogerdv, have you solve the problem and how?
     
  6. rogerdv

    rogerdv

    Joined:
    Jul 16, 2012
    Posts:
    36
    The partial solution is to connect the PC to internet through a VPN (Im in Cuba) and let it do the required download. The second error, caused by some missing file I think, havent been solved yet. Some friends around says that copying some files to offline PCs it can be solved too, but I havent managed to do it.
    My current approach is to use 2018.4 to compile my Android project and 2019 for other projects.