Building Project takes a long time in Unity - c#

I have a project consisting 2 scenes(menu and game). So I added to _game_ scene an interstitial advertisement, after that I faced with gradle build failed error. I resolved it by completely deleting and installed Unity again. But appeared a new issue Building Player, building scene 0: _menu_, It takes for hours, but it didn't take even 5 mins before.
Note: I'm using default Android building files(sdk, ndk, gradle jdk), provided by Unity.
What ideas do you guys can give me?

Related

Compilation error when creating new project in Unity

I'm totally new in Unity and C#, and it's the first time I download Unity.
The problem I'm facing is: Evertime I try to create a totally new project or open an official example project should contain no error, the Unity will say that there are compilation errors in my project, just like the screenshot below:
Error pop-up
This situation will happen in any different version of Unity, I have tried these versions: 2021.3.14, 2020.3.42, 2020.3.25, 2019.4.40.
And the error messages in console of each version are different, in 2021.3.14:
Error message in console
(This kind of disorderly code should be Chinese I think, the reason maybe the Chinese encoded question in Unity. But I don't know why, because the Unity Hub and Unity I installed are all from UK website)
In 2020.3.42 and 2020.3.25:
Error message in console
And in 2019.4.40 the error message is just like the error message in 2020 version, just the "Compiler version 3.5.0-dev" changes to "Compiler version 2.9.1" (I don't have the screenshot cause I have deleted the 2019 version).
Here I'll explain the process I download and install Unity:
I just have an anaconda preinstalled in my computer(which is related to the Unity), and for the first time, I also have the Visual Studio2019 installed in my computer(But I try to uninstall VS2019 before install Unity later, it doesn't work). And I download and install the Unity Hub from official website, then install the Unity 2021.3.14 in Unity Hub. That's all the process, I didn't change anything else in the system about Unity. (There is actually one another thing I have done, but I don't think it's a reason. I download the ml-agents plugin in github, and created a new anaconda environment for it, with just python3.6 and pytorch and ml-agents installed. Then I try to add ml-agents in Unity's packages even it's in compilation error state.)
Here is some info about my computer:
UK computer with Windows11, with anaconda, some jdk and SQL installed.
And here is the list of things I have tried, all from internet:
Change the "Api Compatibility Level*" in Edit->Project Settings->Player->Other Settings->Configuration
Download different version of Unity(as mentioned above)
Delete some packages that may cause this problem
Reimport all the assets of the project
Delete the Unity_lic.ulf file in the directory: C:\ProgramData\Unity and let Unity reload it
Somebody says this may be caused by some antivirus program, so I removed all the antivirus program on my computer (except virus defense program of win11, cause I don't know how to close it and I think it is better to not close it), and completely remove all the Unity files on my computer (probably, I don't know), the remove steps are:
(1) Delete the Unity Editor and Unity Hub files directly
(2) Delete temporary file related to Unity:
C:\ProgramData\Unity
C:\Users\Username\AppData\Local\Unity
C:\Users\Username\AppData\Local\unityhub-updater
C:\Users\Username\AppData\LocalLow\Unity
C:\Users\Username\AppData\Roaming\Unity
C:\Users\Username\AppData\Roaming\UnityHub
(3) Remove all the Unity related folders in windows registry(to ensure the thing I'm saying, to open this, press win+R, then type"regedit"):
HKEY_CURRENT_USER\Software\Unity
HKEY_CURRENT_USER\Software\UnityTechnologie
And reinstall the whole Unity in a totally different directory, to avoid the Unity influenced by the folder path name(like too long, or contains Chinese character), I create a new folder F:\Unity, and create four folder"Download", "Editor", "Hub", "Project" to hold download tem files, Unity Editor, Unity Hub and project file respectively. Then I download and install Unity Hub, then install Unity Editor in Unity Hub, create new project, and everything don't change...
P.S. I also download a Unity use the same process as me on the computer of my roommate. His computer is also win11, with anaconda and Visual Studio preinstalled. And everything went right, it just took me several minutes to successfully create a new project.
Can someone tell me what kind of things can influence the download process of Unity (Like other programming environment or IDE)? And how can I fix this problem?
You tried every possible solution maybe it's time to reinstall a clean windows.

This error is preventing me from building my UWP app on a new Xamarin Form project

I'm beginning my first Xamarin project. I started with setting up an android project and I have gotten it working with the emulator.
But after following the instructions of this video
(https://www.youtube.com/watch?v=mbIvG8ripcw&t=590s&ab_channel=GeraldVersluis)
I get the following error when I try to build:
Expected "!$([System.String]::new('%(ReferenceCopyLocalPaths.Identity)').EndsWith('System.Runtime.dll'))" to evaluate to a boolean instead of "!$([System.String]::new('E:\(PATH TO APP FOLDER)\Notes App\NotesApp\NotesApp\bin\Debug\netstandard2.0\NotesApp.dll').EndsWith('System.Runtime.dll'))", in condition "'$(_CoreFrameworkPackageId)' != ''
AND !$([System.String]::new('%(ReferenceCopyLocalPaths.Identity)').EndsWith('System.Runtime.dll'))
AND '%(ReferenceCopyLocalPaths.NuGetPackageId)' == '$(_CoreFrameworkPackageId)'". NotesApp.UWP
^^ The error code I get for this is MSB4100
I also keep having the Nuget packages Xamarin.Forms and the Microsoft.NETCore.UniversalWindowsPlatform go missing from the references of my project even though they are installed within it. After restarting VS multiple times and toggling on/off settings that alters the project/solution heavily they pop back into existance.
These packages when they go missing give me 10s and I even saw once, 200 errors and they all disappear after turning on and then off again, for example "Compile with .NET Native tool chain" in the build settings.
But the big error above still remains.
========================================
All Nuget packages are up to date and VS is up to date (and I used the repair tool).
I've removed the UWP project and created a new one, and I get the same result.
If anyone can help me solve this and let me know if I've made a silly mistake it would be appreciated. I would like to master this.
If you need any more info let me know, thanks.
Update 1
I've reinstalled my nuget packages and restarted VS and this is my screen. Note I have the package on screen installed but not showing up in my references. Plus some warnings that go away when they feel like it.
Update 2
I created a brand new xamarin android and uwp project template, did not touch a thing, and I tried to build and deploy the uwp project and I get this error
I created a project that was not buring by many layers of folders, in my C drive and not my external exFAT E drive and it now works.
Thanks for your help guys.

Unity error with Firebase RealTime Database

I have been using Unity for a year now and have decided to make a simple chat app. I decided to use Google's Firebase to store my user and chat data. I plan to have the app on android(iOS in the future). My problem is with Unity not being able to generate a Firebase Android File. I searched the error up and it took me to this website. I did the recommend solution and created the realtime database and re installed the json and plist files. It did not work. I still get the following error.
Generation of the Firebase Android resource file google-services.xml from /Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Assets/../Assets/Firebase Data/google-services.json failed.
If you have not included a valid Firebase Android resources in your app it will fail to initialize.
"python" "/Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Library/PackageCache/com.google.firebase.app#7.2.0/Firebase/Editor/generate_xml_from_google_services_json.py" -i "/Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Assets/../Assets/Firebase Data/google-services.json" -o "/Users/Family/Desktop/கலைமாறன்/Unity/STEMastery/Assets/../Assets/Plugins/Android/FirebaseApp.androidlib/res/values/google-services.xml" -p "com.maranstudios.stemastery.maran" ...
I also checked the external tools. Under android it says JDK installed with Unity, Android SDK tools installed with Unity, Android NDK Installed with Unity and Gradle Installed with Unity. I also donwloaded the android studio so I can build to android.
I have also tried to restarted unity, visual studio and even my computer, but that did not help.
Unity runs the program perfectly well on my iMac and can access my RealTime Database in the unity editor. But when I run it on my phone 2 errors pop up.
DllNotFound Exception: Firebase CppApp ...
It can not find the default reference.
2's Explanation:
I have this line of code.
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
I then check in another script if t hat is null. It becomes null on my phone, but works fine on my mac.
I am using macOS Mojave (Version 10.14.4).
My unity version is Unity 2020.3.4f1.
My phone uses android 10.
I have tried everything that I can think of to deal with this error. I believe that by fixing this error, my app will work properly on my phone. I have tried to give all the information needed to help you understand my issues. If I am still missing any, please ask and I will respond as soon as possible.
EDIT :
I tried a couple new things. I upgraded to unity 2020.7, but that did not work. I also tried to create a new project from scratch using Unity 2019, but I am still getting that same error. Could it be that Firebase just doesn't work on my mac or is that this a bug in Unity that has somehow existed over several versions? I really could use some help figuring out to integrate Firebase. Any help is appreciated.
This is a known issue with developers who have non-ascii usernames. See this issue and this issue. It might be worth opening a new issue and highlighting that it's blocking active development right now (note for future readers, the first issue is closed but the second is open as I write. If 690 is also closed with a milestone associated, this means that the issue has been fixed).
For potential workarounds, the best known workaround would be to use a username without any extended non-ascii characters. I know that this can be problematic or disruptive.
You may try disabling persistence in the Editor before making any database calls. This might prevent Firebase from trying to read your local data folder, avoiding the issue:
var database = FirebaseDatabase.DefaultInstance;
if (Application.isEditor) {
database.SetPersistenceEnabled(false);
}
var reference = database.RootReference;
You only have to do this once for your game (so maybe immediately after CheckAndFixDependenciesAsync), but putting it right before database access should makes my example code safer.

Unity Xcode LowLevelCullingLoops.cpp Crash

I've been experiencing a crash when loading the first mission past my menu screen. As soon as my first mission loads, Xcode crashes with this error:
LowLevelCullingLoops.cpp: Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)
Anyone have any idea what this means? I've been trying to debug it for a few days now. Here's some things that Ive done:
Removed all occlusion culling data
Disabled occlusion culling on the camera
Copied all assets into a new scene
Removed 50% of assets from the scene
Cleaning Xcode project
Testing multiple devices
Switched from LWRP to URP
Updated to the newest version of unity (2019.3.2f1)
None of this has resolved my issue. I'm getting crashes on an iPhone 7+ and iPad Pro (2017), both of which are running the latest version of iOS. The crash does not happen when I build for macOS.
Any insights would be appreciated! Thanks.
This crash usually happens whenever camera position is NaN. Try to reset your component or replace it with a new one.

Unity scripts don't work: "Script class cannot be found"

Hello everybody,
A few days ago, a new error showed up on my computer: Unity scripts don't work at all. Every time I try to open (new or old) Unity projects, 2 blank errors appear (first screenshot), and when I try to attach a script to a GameObject, and alert dialog box shows (second screenshot). You can also see in the script import settings: "No MonoBehaviour scripts in the file or their names do not match the file name"...
I already tried to uninstall all Unity's related files, reinstall it, uninstall and reinstall Virtual Studio 2019 and SDKs, so if you have an idea of where it could come from, just tell me!
Thanks a lot,
Simon
The problem you're facing is called "Blank Error". Looking for Blank Error Unity you'll find many possible solutions.
For instance:
https://forum.unity.com/threads/four-blank-errors-in-each-new-project.599980/
What fixed it for me was to "install windows update from this link to your 32 bit or 64 bit system accordingly":
https://support.microsoft.com/en-us/help/2533623/microsoft-security-advisory-insecure-library-loading-could-allow-remot
Ok, so I installed MSVC v140 and v141, Unity 2018.4.13f1 and it seems to work now, after this I tried with Unity 2019.2.15f1, and I think there is an error with this version, I had the same problem.
But right now I can use Unity, that's what I wanted, thanks for all people who helped me !

Categories