Im getting this error when trying to buld my app: Code (CSharp): CommandInvokationFailure: Gradle build failed. 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" stderr[ FAILURE: Build failed with an exception. * What went wrong: Could not resolve all files for configuration ':_internal_aapt2_binary'. > Could not resolve com.android.tools.build:aapt2:3.2.0-4818971. Required by: project : > Could not resolve com.android.tools.build:aapt2:3.2.0-4818971. > 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'. > 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'. > Connect to dl.google.com:443 [dl.google.com/172.217.8.110] failed: Connection timed out: connect > Could not resolve com.android.tools.build:aapt2:3.2.0-4818971. > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom'. > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom'. > jcenter.bintray.com * 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 38s ] stdout[ :checkReleaseClasspath :preBuild UP-TO-DATE :preReleaseBuild :compileReleaseAidl NO-SOURCE :compileReleaseRenderscript :checkReleaseManifest :generateReleaseBuildConfig :prepareLintJar :mainApkListPersistenceRelease :generateReleaseResValues :generateReleaseResources :mergeReleaseResources FAILED 9 actionable tasks: 9 executed ] exit code: 1 UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <177bc8179be6497489c4b5b319f290d7>: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 <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <177bc8179be6497489c4b5b319f290d7>: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 <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <177bc8179be6497489c4b5b319f290d7>: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 <177bc8179be6497489c4b5b319f290d7>:0) UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <177bc8179be6497489c4b5b319f290d7>: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) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) 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?
I think I found them: this is libTemplate.gradle Code (CSharp): buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.0' } } apply plugin: 'android-library' dependencies { implementation fileTree(dir: 'bin', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar']) } android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' //java.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs'] } } compileSdkVersion **APIVERSION** buildToolsVersion '**BUILDTOOLS**' defaultConfig { targetSdkVersion **LIBSDKTARGET** } lintOptions { abortOnError false } } and thi sis mainTemplate.gradle Code (CSharp): // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.0' **BUILD_SCRIPT_DEPS**} } allprojects { repositories { google() jcenter() flatDir { dirs 'libs' } } } apply plugin: 'com.android.application' **APPLY_PLUGINS** dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) **DEPS**} android { compileSdkVersion **APIVERSION** buildToolsVersion '**BUILDTOOLS**' compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { minSdkVersion **MINSDKVERSION** targetSdkVersion **TARGETSDKVERSION** applicationId '**APPLICATIONID**' ndk { abiFilters **ABIFILTERS** } versionCode **VERSIONCODE** versionName '**VERSIONNAME**' } lintOptions { abortOnError false } aaptOptions { noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**] ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~" }**SIGN** buildTypes { debug { minifyEnabled **MINIFY_DEBUG** useProguard **PROGUARD_DEBUG** proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG** jniDebuggable true } release { minifyEnabled **MINIFY_RELEASE** useProguard **PROGUARD_RELEASE** proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG** } }**PACKAGING_OPTIONS****SPLITS** **BUILT_APK_LOCATION** **EXTERNAL_SOURCES** bundle { language { enableSplit = false } density { enableSplit = false } abi { enableSplit = true } } }**SPLITS_VERSION_CODE****REPOSITORIES****SOURCE_BUILD_SETUP**
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.