Related
Mono is installed, everything is installed, but it can't load the .csproj file from Unity. Outputs an error:
Starting OmniSharp server at 26/2/2022, 8:26:37 am
Target: /E/projects/My project/My project.sln
OmniSharp server started with Mono 6.12.0.
Path: /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/OmniSharp.exe
PID: 30651
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on arch 0.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to /usr/share/dotnet/dotnet
[warn]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
It looks like you have Mono 6.4.0 or greater installed but MSBuild could not be found.
Try installing MSBuild into Mono (e.g. 'sudo apt-get install msbuild') to enable better MSBuild support, or upgrade to latest Mono: https://www.mono-project.com/download/stable/.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 17.1.0 - "/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 17.1.0 - "/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/E/projects/My project'.
[info]: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/E/projects/My project/My project.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/E/projects/My project/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/E/projects/My project'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/E/projects/My project' on host 30408.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /E/projects/My project/Assembly-CSharp.csproj
Can't find custom attr constructor image: /E/projects/My project/Library/ScriptAssemblies/Unity.Rider.Editor.dll mtoken: 0x0a000007 due to: Could not find method '.ctor' due to a type load error: Could not set up parent class, due to: Could not set up parent class, due to: assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null)
[fail]: OmniSharp.MSBuild.ProjectLoader
The "ResolveAssemblyReference" task failed unexpectedly.
System.TypeLoadException: Could not find method '.ctor' due to a type load error: Could not set up parent class, due to: Could not set up parent class, due to: assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null)
at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesDataInternal(System.Reflection.ICustomAttributeProvider)
at System.MonoCustomAttrs.GetCustomAttributesDataBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00010] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.MonoCustomAttrs.GetCustomAttributesData (System.Reflection.ICustomAttributeProvider obj, System.Boolean inherit) [0x00011] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.CustomAttributeData.GetCustomAttributes (System.Reflection.Assembly target) [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.RuntimeAssembly.GetCustomAttributesData () [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetFrameworkName () [0x00025] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation.get_FrameworkNameAttribute () [0x00028] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata..ctor (System.String path) [0x00019] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation+<>c.<GetAssemblyMetadata>b__21_0 (System.String p) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00006] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference+<>c.<Execute>b__255_4 (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.SystemState.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00010] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.GetUnifiedAssemblyMetadata (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.IEnumerable`1[Microsoft.Build.Tasks.UnifiedAssemblyName]& unifiedDependencies, System.String[]& scatterFiles) [0x00023] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindDependenciesAndScatterFiles (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.List`1[T] newEntries) [0x0003a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindAssociatedFiles () [0x000ea] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure () [0x0000a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure (System.Collections.Generic.IEnumerable`1[T] remappedAssembliesValue, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyFiles, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyNames, System.Collections.Generic.List`1[T] exceptions) [0x00038] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute (Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.DirectoryExists directoryExists, Microsoft.Build.Tasks.GetDirectories getDirectories, Microsoft.Build.Tasks.GetAssemblyName getAssemblyName, Microsoft.Build.Tasks.GetAssemblyMetadata getAssemblyMetadata, Microsoft.Build.Shared.GetRegistrySubKeyNames getRegistrySubKeyNames, Microsoft.Build.Shared.GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, Microsoft.Build.Tasks.GetLastWriteTime getLastWriteTime, Microsoft.Build.Tasks.GetAssemblyRuntimeVersion getRuntimeVersion, Microsoft.Build.Shared.OpenBaseKey openBaseKey, Microsoft.Build.Tasks.GetAssemblyPathInGac getAssemblyPathInGac, Microsoft.Build.Tasks.IsWinMDFile isWinMDFile, Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader) [0x00515] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute () [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <29047405fcfe41bbb744a55b7d0f20fa>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002fb] in <29047405fcfe41bbb744a55b7d0f20fa>:0
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/E/projects/My project/Assembly-CSharp.csproj'.
/E/projects/My project/Assembly-CSharp.csproj
/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(2301,5): Error: The "ResolveAssemblyReference" task failed unexpectedly.
System.TypeLoadException: Could not find method '.ctor' due to a type load error: Could not set up parent class, due to: Could not set up parent class, due to: assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null)
at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesDataInternal(System.Reflection.ICustomAttributeProvider)
at System.MonoCustomAttrs.GetCustomAttributesDataBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00010] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.MonoCustomAttrs.GetCustomAttributesData (System.Reflection.ICustomAttributeProvider obj, System.Boolean inherit) [0x00011] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.CustomAttributeData.GetCustomAttributes (System.Reflection.Assembly target) [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.RuntimeAssembly.GetCustomAttributesData () [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetFrameworkName () [0x00025] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation.get_FrameworkNameAttribute () [0x00028] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata..ctor (System.String path) [0x00019] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation+<>c.<GetAssemblyMetadata>b__21_0 (System.String p) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00006] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference+<>c.<Execute>b__255_4 (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.SystemState.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00010] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.GetUnifiedAssemblyMetadata (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.IEnumerable`1[Microsoft.Build.Tasks.UnifiedAssemblyName]& unifiedDependencies, System.String[]& scatterFiles) [0x00023] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindDependenciesAndScatterFiles (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.List`1[T] newEntries) [0x0003a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindAssociatedFiles () [0x000ea] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure () [0x0000a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure (System.Collections.Generic.IEnumerable`1[T] remappedAssembliesValue, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyFiles, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyNames, System.Collections.Generic.List`1[T] exceptions) [0x00038] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute (Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.DirectoryExists directoryExists, Microsoft.Build.Tasks.GetDirectories getDirectories, Microsoft.Build.Tasks.GetAssemblyName getAssemblyName, Microsoft.Build.Tasks.GetAssemblyMetadata getAssemblyMetadata, Microsoft.Build.Shared.GetRegistrySubKeyNames getRegistrySubKeyNames, Microsoft.Build.Shared.GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, Microsoft.Build.Tasks.GetLastWriteTime getLastWriteTime, Microsoft.Build.Tasks.GetAssemblyRuntimeVersion getRuntimeVersion, Microsoft.Build.Shared.OpenBaseKey openBaseKey, Microsoft.Build.Tasks.GetAssemblyPathInGac getAssemblyPathInGac, Microsoft.Build.Tasks.IsWinMDFile isWinMDFile, Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader) [0x00515] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute () [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <29047405fcfe41bbb744a55b7d0f20fa>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002fb] in <29047405fcfe41bbb744a55b7d0f20fa>:0
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /E/projects/My project/Assembly-CSharp.csproj
Am I missing anything? C# extensions are installed along with Unity extensions. Mono is also installed. I'm using Arch Linux, latest version and installed visual-studio-code-bin. Unity > External Tools > Generate .csproj files for Local packages.
This workaround on github comment fixed it for me.
Set the VS Code omnisharp setting "Use Modern Net" to true.
(This also entails installing dotnet sdk 6.x, and from what I see uses that version to build the projects, not sure if that breaks stuff for people using previous versions.)
Here's a screenshot of the extension settings:
I'm trying to build my android app for a while and can't seem to find any solution for this problem:
Image
Unity Version: Unity 2020.3.21f1 (64-bit)
JDK, SDK, NDK and Gradle used are Unity's recommended ones (already tried to use other ones).
The console details are here:
Configure project :launcher
WARNING: The option setting 'android.enableR8=false' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)`
FAILURE: Build failed with an exception.
* What went wrong:
com/sun/istack/FinalArrayList
* 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.
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2020.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2020.3.21f1\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.
Build completed with a result of 'Failed' in 60 seconds (59527 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <208f92fc783546f9abbe643bfc23920c>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <208f92fc783546f9abbe643bfc23920c>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
I already tried all tutorials on youtube and other forums, but every help is welcome, thanks!
Edit 1:
After trying Jaimin's solution this is happening now:
Assets/Plugins/Android\gradleTemplate.properties file is using a deprecated way of controlling which tool should be used to do the minification. To fix this, remove "useProguard" entries yourself. If not fixed, your build can fail.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
File C:\Users\Windows\.android\repositories.cfg could not be loaded.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
FAILURE: Build failed with an exception.
* What went wrong:
com/sun/istack/FinalArrayList
> com.sun.istack.FinalArrayList
* 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 5s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2020.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2020.3.21f1\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.
* What went wrong:
com/sun/istack/FinalArrayList
> com.sun.istack.FinalArrayList
* 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 5s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <f94168442e634613b6a5965ed17c38f4>: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 <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <f94168442e634613b6a5965ed17c38f4>: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 <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <f94168442e634613b6a5965ed17c38f4>: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 <f94168442e634613b6a5965ed17c38f4>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <f94168442e634613b6a5965ed17c38f4>: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 <208f92fc783546f9abbe643bfc23920c>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Build completed with a result of 'Failed' in 127 seconds (127448 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 5 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <208f92fc783546f9abbe643bfc23920c>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <208f92fc783546f9abbe643bfc23920c>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
And here's how the Custom Gradle Properties Template file is coded:
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
**ADDITIONAL_PROPERTIES**
This is because android.enableR8 is deprecated. To remove it from your gradle.properties file you have to go to Project Settings > Player > Android (Tab) > Other Settings > and check Custom Gradle Properties Template.
After that, a gradleTemplate.properties file is generated at:
Assets/Plugins/Android/gradleTemplate.properties
In this file, remove line android.enableR8, or comment it out, and now make new fresh build.
This trick should work.
Alternatively, export as an Android project and then change it in Android Studio. In Android Studio, you have more control on these things.
Install a new version of Unity, it will work
You can use the Unity 2020.3.33f1 version, that's the one I use, and it works fine.
Remember to set to Preferences: Unity default JDK, Gradle, NDK
I have seen in a lot of places and the issue is really painfull. In my case, my problem it was that there was an old CSharp interface of mine incorrect that wasn't in my csproj, so I couldn't see in my Visual Studio.
As Unity doesn't care about csproj, it uses it in compilation. I just noticed because of an inexistent java issue shown in Console window (because of Android, the CSharp was converted to Java and for this reason Graddle threw the issue).
Try to find in your CSharp program some class that doesn't appear in Solution Explorer in Visual Studio and remove or fix it.
Also, I followed the fix indicated above by Jaimin. It didn't work for me, but I left like that. It makes way more sense with it.
Try This
For Windows
go to the location
"C:\Program Files\Unity\Hub\Editor\2021.1.24f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\31.0.0"
find a file named d8.bat. This is a Windows batch file.
rename d8.bat to dx.bat.
in the folder lib ("C:\ProgramFiles\Unity\Hub\Editor\2021.1.24f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\31.0.0\lib")
rename d8.jar to dx.jar
Remember AppData is a hidden folder. Turn on hidden items to see the AppData folder.
Now run your project...
From ELNexs
https://forum.unity.com/threads/gradle-error-problem-with-gradle-build.538320/
Unity version = Unity 2018.2.10f1
JDK = jdk1.8.0_191
PROBLEM:
CommandInvokationFailure: Gradle build failed. C:/Program
Files/Java/jdk1.8.0_191\bin\java.exe -classpath "C:\Program
Files\Unity\Hub\Editor\2018.3.0f2\Editor\2018.2.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.1.jar"
org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m"
"assembleRelease"
stderr[
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'gradleOut'.
Could not resolve all files for configuration ':classpath'.
Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/manifest-merger/26.0.1/manifest-merger-26.0.1.jar
Could not find ddmlib.jar (com.android.tools.ddms:ddmlib:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/26.0.1/ddmlib-26.0.1.jar
Could not find dvlib.jar (com.android.tools:dvlib:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/dvlib/26.0.1/dvlib-26.0.1.jar
Could not find common.jar (com.android.tools:common:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/common/26.0.1/common-26.0.1.jar
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1s ] stdout[
] exit code: 1 UnityEditor.Android.Command.WaitForProgramToRun
(UnityEditor.Utils.Program p,
UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit,
System.String errorMsg) UnityEditor.Android.Command.Run
(System.Diagnostics.ProcessStartInfo psi,
UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit,
System.String errorMsg) UnityEditor.Android.AndroidJavaTools.RunJava
(System.String args, System.String workingdir, System.Action1
progress, System.String error) UnityEditor.Android.GradleWrapper.Run
(UnityEditor.Android.AndroidJavaTools javaTools, System.String
workingdir, System.String task, System.Action1 progress) Rethrow as
GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run
(UnityEditor.Android.AndroidJavaTools javaTools, System.String
workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute
(UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks
(UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
1)I have tried Changing the manifest for target sdk ...
2)clearing the gradle folder in user..
3)downgraded some sdk
Still can't build ...same error again and again.
Just upgrading it to Unity 2018.3.0f2 solved my problem
May be late, but I've fixed that issue by deleting the playcore.arr file from Assets/GooglePlayPlugins/com.google.play.core/Runtime/Plugins
When i build an agora apk
I got this
CommandInvokationFailure: Gradle build failed.
F:\Unity_2018.3.f1\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "F:\Unity_2018.3.f1\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.
Where:
Build file 'C:\Users\UNI\Downloads\AMG_FULL_Unity_v2_2_3_20\AMG_FULL_Unity\samples\Hello-Video-Unity-Agora\Temp\gradleOut\build.gradle' line: 17
What went wrong:
A problem occurred evaluating root project 'gradleOut'.
Failed to apply plugin [id 'com.android.application']
Gradle version 2.10 is required. Current version is 4.6. If using the gradle wrapper, try editing the distributionUrl in C:\Users\UNI\Downloads\AMG_FULL_Unity_v2_2_3_20\AMG_FULL_Unity\samples\Hello-Video-Unity-Agora\Temp\gradleOut\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
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 29s
]
stdout[
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Cause of issue: If you are using an older version of the plugin (current version 2.4), there is an issue with the Gradle file that was included (was meant for older versions of Unity). Newer versions of Unity ship with a new version of Gradle which is causing the compile errors where Unity throws an error “Unable to build gradle”.
To resolve: Open your file explorer and navigate into the project Assets > Plugins > Android and delete the mainTemplate.gradle file.
We have a Xamarin.Forms android and ios app which has been performing well for a number of years now. The latest version has been in prod since early 2017, and has had very few crashes. Until recently!
One of our android clients started getting exceptions when connecting to our ServiceStack powered API service. Now our API service hasn't been changed since the App deployment (Jan 2017), and we've just started getting these errors in Dec 2017.
The details from the app logging on their device reveal the following.
Exception: The type initializer for 'System.AndroidPlatform' threw an exception.StackTrace: at System.Net.WebProxy.CreateDefaultProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetSection () [0x00015] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.get_InternalDefaultWebProxy () [0x00022] in <10a067eff09446018662189377d200e9>:0
at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x0008d] in <10a067eff09446018662189377d200e9>:0
at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:.ctor (System.Uri)
at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x00091] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.String requestUriString) [0x00014] in <10a067eff09446018662189377d200e9>:0
at ServiceStack.PclExport.CreateWebRequest (System.String requestUri, System.Nullable`1[T] emulateHttpViaPost) [0x00000] in <0c56e395a4c44995b59b57d9e7ca7331>:0
at ServiceStack.ServiceClientBase.PrepareWebRequest (System.String httpMethod, System.String requestUri, System.Object request, System.Action`1[T] sendRequestAction) [0x0004e] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.SendRequest (System.String httpMethod, System.String requestUri, System.Object request) [0x00014] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Send[TResponse] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00075] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (System.String relativeOrAbsoluteUrl) [0x00000] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (ServiceStack.IReturn`1[T] requestDto) [0x00012] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at [OUR APP].PCL.Services.Agent.IsAwake () [0x00013] in <cb1d96a8f02e4d9f92152b248e31ee23>:0
Source: System
Has Inner Exceptions: True
Inner Exception 1: Couldn't bind to method 'CertStoreLookup'.
StackTrace: at System.Delegate.GetCandidateMethod (System.Type type, System.Type target, System.String method, System.Reflection.BindingFlags bflags, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x000f9] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x00014] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.AndroidPlatform..cctor () [0x0002d] in <10a067eff09446018662189377d200e9>:0
Source: mscorlib
Has Inner Exceptions: False
25/01/18 11:01:19 IsAwake The type initializer for 'System.AndroidPlatform' threw an exception. Endpoint http://OURENDPOINT/
25/01/18 11:01:18 Sync Started
I have been able to reproduce this error, but only in a release build. It all works fine in DEBUG mode, when using the Shared Runtime Framework. So it's leading me to think that the release build packaging of Android is removing something that Android requires, but I can't for the life of me figure out what it is.
Version Info
VS2017 15.5.6
Xamarin 4.8.0.760
Xamarin.Android SDK 8.1.5.0
Xamarin.Forms v1.5.0.6447 (in PROD)
ServiceStack.Client (PCL proj via NuGet) 4.0.40 (in PROD)
Installed SDK's
8.0.0(26), 7.1.1(25), 7.0(24), 6.0(23), 5.01(21), 4.4.2(19),
Build Config
Target Framework: 6.0 (v23)
Minimum SDK: 4.0.3 (v15)
**DEBUG**
Use Shared Runtime : true
Use Fast Deploy : false
Linking: SDK Assemblies only
**RELEASE**
Use Shared Runtime : false
Use Fast Deploy : false
Linking: none
I've been trying many things..
I've updated the Target Framework to 7.1 with minimum to 5.0, removed all Xamarin and ServiceStack references, and then installed the new ones that target the framework level.
Everything always works in DEBUG, but not in RELEASE.
Would greatly appreciate any assistance anyone could supply..
TIA.
EDIT
After performing the steps suggested by #mahmoud-kamel, I get the following errors for the RELEASE build.
Severity Code Description Project File Line Source Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void Android.Support.V4.App.FragmentActivity::n_OnRequestPermissionsResult_IarrayLjava_lang_String_arrayI(System.IntPtr,System.IntPtr,System.Int32,System.IntPtr,System.IntPtr)' in assembly: 'Xamarin.Android.Support.Fragment.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.App.Activity::OnRequestPermissionsResult(System.Int32,System.String[],Android.Content.PM.Permission[])
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [OUR APP].DroidApp C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1696 Build
This turned out to be a mismatch of assemblies referenced by the project.
After looking at the internals of the System.dll's in the bin/debug and bin/release folders, and comparing those of a new project from VS template, we were able to determine that after the project was upgraded to use the latest SDK, MSBuild wasn't retrieving the SYSTEM.dll from the correct ReferenceAssemblies folder location.
Doing a search for "ReferenceAssemblies" on my pc brings up about 4 locations!
The correct location (on my pc) is the following folder, with the Android version number folder (eg. "v8.0".
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\
I hope this helps someone and saves them the hours I spent on this!
put Target framework to the latest and the minimum is version 16
right click on Android project then go to options make sure that Release mode in linker tab and choose link SDK Assemblies only
save all changes then clean all solution , close the project and visual studio
go to folder of project then delete bin, obj folders
open visual studio , and try to start deploy project in release mode