Unity3D problems building on MacOS - c#

I'm trying to "build" a game project made on Unity3D, but keep getting errors unrelated to the code; as far as I understand.
Unity 3D version 2018.3.0f2
MacBook Pro, MacOS Mojave v. 10.14.2
The game runs fine on this and two other devices which run a Windows 10 OS. It builds without problems on the Windows OS, but not on the MacOS.
The project is the exact same; copied via flash-drive to transfer between the two, and pulled as a git project.
I have tried installing Unity3D via the install assistant, and via Unity Hub; neither made a difference.
I made sure all required dependencies were installed, and re-installed multiple times. Clean installs, restarts, even the OS was re-installed as I had literally just gotten this laptop to work on my Unity game-dev projects.
After many failed attempts, I made a partitioned drive specifically for this project, re installed everything and ran the project for the firs time. Test played it, it ran well, but still wouldn't build. I did that because I thought it was a security or "access rights" problem.
With that, I even allowed Unity access to the whole drive via the security settings of the Mac OS.
[1] https://imgur.com/q4prwXh "Error Screenshot".
What was expected was that the project would build without problems; what happened was that I got these errors which I will try to post a picture of.
The error in text in-case screenshot doesn't work:
[1]
UnauthorizedAccessException: Access to the path "/Volumes/(edited >out)/Temp/StagingArea/Data/Managed/Unity.Analytics.StandardEvents.dll" >is denied.
System.IO.File.Delete (System.String path) (at :0)
UnityEditorInternal.AssemblyStripper.RunAssemblyStripper (System.Collections.IEnumerable assemblies, System.String managedAssemblyFolderPath, System.String[] assembliesToStrip, System.String[] searchDirs, System.String monoLinkerPath, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr, UnityEditor.ManagedStrippingLevel managedStrippingLevel) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:372)
UnityEditorInternal.AssemblyStripper.StripAssemblies (System.String managedAssemblyFolderPath, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr, UnityEditor.ManagedStrippingLevel managedStrippingLevel) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:216)
UnityEditorInternal.IL2CPPBuilder.Run () (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:203)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:42)
DesktopStandalonePostProcessor.SetupStagingArea (UnityEditor.Modules.BuildPostProcessArgs args, System.Collections.Generic.HashSet1[T] filesToNotOverwrite) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:245)
DesktopStandalonePostProcessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:46)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
[2]
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00234] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:190
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:96
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Thank you for the help.

If anyone has problems building their Unity3D project on a Mac, I may have found a solution for my problem that could help others.
Two things, one of which may have been the cause of it.
1) I basically ran the Packages Manager within Unity, and removed all packages that were initially added via the Windows version of Unity3D (for Android). I don't know much about this part, but that worked.
2) You need to download and install the latest Xcode from the AppStore, run it with template project (something to make it run and start up); that way it downloads any dependencies or required files. Then, close project, restart the computer, and once back; run your Unity3D project and try building again.
That basically fixed it for me, as there were certain files in the project that needed some "access rights" that were not possible without Xcode being there and installed; which, I think, allows those things to happen.
I hope that helps others.
Best of luck.

Related

Unity no longer able to build project

I've been banging my head against the wall the last 6 days or so trying to get Unity to build my Android game.
My game used to build as it should a few months back, I had a couple new things I came up with and added those (the game runs fine within Unity, there are no errors in play mode).
Trying to build my game with the C++ compiler set to the 'master', however, consistently fails, with the following exceptions:
1.
Building Library\Bee\artifacts\Android\fy9m9\libil2cpp.so failed with output:
C:/Program Files/Unity/Hub/Editor/2021.3.14f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld.gold.exe: internal error in arm_branch_common, at /buildbot/src/android/binutils/toolchain/binutils/binutils-2.27/gold/arm.cc:4063
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
BuildFailedException: Incremental Player build failed!
UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <6a5b55f2e18b419e9faedac06ac6af94>:0)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <6a5b55f2e18b419e9faedac06ac6af94>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <b5a1f7b6d39d4ca78ca284153b2ea92d>: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 <6a5b55f2e18b419e9faedac06ac6af94>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Build completed with a result of 'Failed' in 668 seconds (667590 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <6a5b55f2e18b419e9faedac06ac6af94>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <6a5b55f2e18b419e9faedac06ac6af94>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Things I've tried so far:
Building with the C++ Compiler Configuration set to 'release' also compiles
I can build the project if I switch the platform to Windows
It seems the project can build if I set the compiler to 'debug' instead of 'master', this does not solve the problem, but might be a clue to the actual problem(?)
Making sure it was not caused by something I added: I loaded up the backup of my game (version 1.0, which worked fine and is also published), but the backup can also no longer be build.
Making sure the problem is not with Unity itself, I tried to do a build of a clean project. This works as expected.
I updated all packages in my project
I updated the Unity version my project uses to 2021.3.14f1 (which I also use for another Android project, which can be build with that version).
Updated the Google Play Games for Unity Plugin (https://github.com/playgameservices/play-games-plugin-for-unity) and accompanying code changes that were required
Per response on Reddit, I made sure that no script uses the UnityEditor namespace (the few that do, are put with #IF UNITY_EDITOR commands
Thanks to user jdweng I managed to find the problem by looking at it from a different angle. Which led me to a post on the Unity Forums with someone who has the exact same problem I described: https://forum.unity.com/threads/fails-to-compile-on-android-arm-32.1135633/
One user there mentions a solution (credits to pradotech), which ended up fixing the problem for me:
I could build for Android using Master compiler after changing
Stripping Level to Medium (I was using Low) and switching from .NET
Framework to .NET Standard 2.1. Details below:
Unity 2021.3.9f1
Faster runtime
Compression: LZ4HC API
Compatibility: .NET Standard 2.1
Compiler Configuration: Master
All architectures (ARMv7, ARM64, x86 and x86-64)
Managed Stripping Level: Medium/High
I also removed some unused scripts from project.
Build completed without any errors.
Hope it keeps working and maybe that helps someone.
My project is using Unity 2021.3.14f1, I was already on .Net Standard 2.1.
I changed stripping to Medium, removed a bunch of deprecated scripts and now it works again.

<SOLVED> Unity & MySQL | Scripts work in editor but not in build

I have created a simple Unity application that uses MySQL. The app works perfectly in the Unity Editor, however when I build it for PC Standalone or Android, it does not work.
After checking the log files, the following exception has been thrown
PlatformNotSupportedException: Operation is not supported on this platform.
at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in <5bca8ad0d7cb4bf194403b342b8f0938>:0
Rethrow as TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception.
at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x0001e] in <5bca8ad0d7cb4bf194403b342b8f0938>:0
Rethrow as TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x002be] in <5bca8ad0d7cb4bf194403b342b8f0938>:0
at Main.Start () [0x0008b] in <7257cb8e307a4c4d92671557aa30bf0e>:0
at Main.Update () [0x0000d] in <7257cb8e307a4c4d92671557aa30bf0e>:0
How can MySQL not be supported on either of my platforms (both Android and PC Standalone) yet it works in Unity editor? Furthermore, I have recently created another game that also uses MySQL and works fine on all platforms. What could be the issue?
Feel free to ask me for code files, Unity files or whatever you think you need to help me solve the issue. Thank you!
Edit: Solved | just changed the API compatibility settings to .NET 4.x
I think this because of API Compatibility Level, here are the references to similar problems:
link 1
link 2
API Compatibility Level can be found in:
File > Build Settings > Player Settings > Player > Configuration

How to use the VLC.DotNet.Core API on Raspberry Pi

I've made a C# console application which compiles with mono (mcs) and I can run that on both Windows and Raspberry Pi (raspbian). The application uses the NuGet package Vlc.DotNet.Core to interface with the VLC installation that exists on my Windows machine, and this works.
I know the path to libvlc.dll (which the api requires in order to work) on my Windows machine, the problem is that I can't find that on the Raspberry Pi even after installing VLC on there with apt-get install vlc.
I've searched the Pi for the location of vlc, and entered that path into the constructor of VlcMediaPlayer as follows;
new VlcMediaPlayer(new DirectoryInfo("/usr/lib/arm-linux-gnueabihf/vlc"));
I have very little confidence that I've used the correct path... Clearly there are major differences between VLC's Windows installation and the one for Raspbian.
The resulting exception on the Pi reads:
Unhandled Exception:
System.IO.FileNotFoundException: Unable to find the specified file.
at Vlc.DotNet.Core.Interops.VlcLibraryLoader..ctor (System.IO.DirectoryInfo dynamicLinkLibrariesPath) [0x0007a] in <baf298be89ec4e8f88b59dde806086ea>:0
at Vlc.DotNet.Core.Interops.VlcLibraryLoader.GetOrCreateLoader (System.IO.DirectoryInfo dynamicLinkLibrariesPath) [0x00051] in <baf298be89ec4e8f88b59dde806086ea>:0
at Vlc.DotNet.Core.Interops.VlcManager..ctor (System.IO.DirectoryInfo dynamicLinkLibrariesPath, System.String[] args) [0x00006] in <baf298be89ec4e8f88b59dde806086ea>:0
at Vlc.DotNet.Core.VlcMediaPlayer..ctor (System.IO.DirectoryInfo vlcLibDirectory) [0x00000] in <9af967e78de14038abf8c3386a2b8049>:0
at MonoApp.Classes.VLCFactory.Create () [0x0000b] in <0b03f50fed2542db8a444bf356ef64b6>:0
at MonoApp.Classes.VLCCommands.VLCCommand_Play.Execute (Vlc.DotNet.Core.VlcMediaPlayer& mediaPlayer, System.String[] args) [0x00007] in <0b03f50fed2542db8a444bf356ef64b6>:0
at MonoApp.Program.Main (System.String[] args) [0x00019] in <0b03f50fed2542db8a444bf356ef64b6>:0
EDIT:
I've found the source files to the VlcLibraryLoader class (as seen in the exception) here, and apparently it's looking for three dlls, only two of which exist on Windows so I'm guessing that the linked source files are slightly outdated. The point here is that they're looking for .dll files, not the .so files that exist on the Raspberry Pi, so I'm not surprised it's failing. The question remains, however...
QUESTION:
Am I using the correct vlc package libvlc-dev, are there any other dependencies I need?
Is Vlc.DotNet.Core API known to work on Raspbian with mono or am I on a hopeless path?
I don't know if Vlc.DotNet.Core can be made to work on raspbian with mono. It is initially targetted to work on Windows, as you know.
LibVLCSharp probably will work on raspbian though, since it works with ubuntu.
LibVLC/GTK linux install guide: https://code.videolan.org/videolan/LibVLCSharp/blob/master/docs/linux-setup.md
LibVLCSharp.GTK sample: https://code.videolan.org/videolan/LibVLCSharp/tree/master/Samples/LibVLCSharp.GTK.Sample
Good luck.

Unity Build Error : ('Assets/Plugins/UnityPurchasing/Bin/Stores.dll') : the dll is not allowed to be included or could not be found

I am trying to build an APK (for Android) in Unity 2017, but get a strange build error.
Here are what I have done:
(1) I have already imported Unity IAP, and have verified that the lib Store.dll actually exists inside the folder "Assets/Plugins/UnityPurchasing/Bin/Stores.dll"
(2) I have changed the Build Settings > Player Settings > API Compatibility Level to Net 2.0.
However, I still have this build error:
ArgumentException: The Assembly UnityEngine.Purchasing is referenced by Stores ('Assets/Plugins/UnityPurchasing/Bin/Stores.dll'). But the dll is not allowed to be included or could not be found.
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary2 cache, BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:156)
UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:196)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Please let me know how to fix this build error. Thanks.
I have solved this issue.
Basically, I need to ENABLE the IAP purchase option as follow: Go to the Unity menu bar -> Click on Window -> Services -> In App Purchase -> Enable.
After that, the build works fine.
--
PS: I was switching projects a few times and forgot to re-enable the IAP in the new project. That was the reason for this bug to show up.

Unity gradle build failed

I can't build another APK in Unity. Always the same error.
CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_171\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.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'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 27.0.1].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 1s
]
stdout[
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\m-pro\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Checking the license for package Android SDK Build-Tools 27.0.1 in C:\Users\m-pro\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Build-Tools 27.0.1 not accepted.
]
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.Action`1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (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)
My settings and things I've tried:
JDK version 1.8
SDK build tool version 25
I tried to copy "-dontwarn com.google.vr.ndk.base.DaydreamApi" into a proguard file (saw this type of a solution somewhere)
Swap from gradle build to internal build (as internal build a different error comes up)
Reinstall all and restart my computer :D
I had this same issue with my Unity builds after the build tools got an update, so you may just have to update them too.
as it says in the error message you need to accept the TOS using android studio
You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 27.0.1].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Install Android studio on your PC (if you havn't already)
run its SDK manager (configure > SDK manager > SDK tools)
If Android SDK build-tools says "Not installed", click the checkbox right next to it to install it.
if It says "Update available" click the checkbox with the "-" next to it so it shows a "✓"
hit apply, and accept the agreement.
That is what fixed it for me, hope this also works for you!
On OSX, I ran into this after upgrading from Unity 2020.3.24f1 to Unity 2020.3.38f1
What fixed it for me was getting the JDK and SDK paths from the Unity/Preferences/external tools, then in a terminal window:
export JAVA_HOME=<the JDK path Unity is using>
<SDK path Unity is using>/tools/bin/sdkmanager --licenses
for me this was:
export JAVA_HOME=/Applications/Unity/Hub/Editor/2020.3.38f1/PlaybackEngines/AndroidPlayer/OpenJDK
/Applications/Unity/Hub/Editor/2020.3.38f1//PlaybackEngines/AndroidPlayer/SDK/tools/bin/sdkmanager --licenses
This will then prompt to accept several licenses which appear under
/Applications/Unity/Hub/Editor/2020.3.38f1/PlaybackEngines/AndroidPlayer/SDK/licenses
Without the export JAVA_HOME to Unity's version, the sdkmanager --licenses would fail with a Java error.
After I figured this out on my own, I happened to notice the solution in Unity forums as well here: https://forum.unity.com/threads/gradle-build-faled.999773/

Categories

Resources