MirjaKop
MirjaKop

Reputation: 13

Unity project stopped building in a reinstalled editor

I have a project that built just fine, then i had to reinstall unity and download the specific editor that I was using (21.3.4f1). Now my project will not build, or builds with corrupt (jittery) scenes. First i thought it was a broken scene and replaced it, but then realised that older separately stored versions also have a build problem, while they had not been touched since August, when they were building fine. What could be the problem? Has anyone else experience of this? I am new to Unity and this is my first bigger project.

I tried to:

*replaced the scene, no effect, scene jittely and crashed in a build.

opened older (branch) versions that had no problems,some did fail to build, some were similarly broken, some were broken in another scene.

erors in the console: UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <36f62d8e760b48f7af5d32916f997ce1>:0 at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <36f62d8e760b48f7af5d32916f997ce1>:0 UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

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 Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

FAILURE: Build failed with an exception.

Could not initialize class javax.crypto.JceSecurity

BUILD FAILED in 2s Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

tried to open a project version with a newer editor. The project opened only in a safe mode with 2 fatal errors: Assets\Oculus\VR\Editor\OVRDeviceSelector.cs(45,20): error CS1061: 'OculusSettings' does not contain a definition for 'TargetQuest' and no accessible extension method 'TargetQuest' accepting a first argument of type 'OculusSettings' could be found (are you missing a using directive or an assembly reference?)

and

Unloading broken assembly Library/ScriptAssemblies/Unity.Rider.Editor.dll, this assembly can cause crashes in the runtime

and also:

Multiple ADB server instances found, the following ADB server instance have been terminated due to being run from another SDK. Process paths: C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\adb.exe

In all these cases, the problem is in the editor I'm using?

Upvotes: 1

Views: 480

Answers (1)

Patrick Moling
Patrick Moling

Reputation: 145

Building an Android application is always pain with Unity, there are a lot of potential reasons why your app is not building and the logcat is usually not accurate about it. When changing Unity version, you are also changing Java SDK, NDK, Build-Tools and also the Gradle, so if you are targeting Android Api 33, the first thing that you need to do is installing the right SDK Build-Tools.

I suggest you to follow this video (you install the build tools for Android API 33), it worked out well for my project.

In the video he doesn't show anything about "gradleTemplate.propreties", but after some research I found out that you have to add "useAndroidX" and "enableJetifier", just like this:

org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
unityStreamingAssets=**STREAMING_ASSETS**
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**

Remember to resolve the dependencies after you have completed all of the above steps since the dependency resolution method has changed, now the plugins will be written inside "mainTemplate.gradle" instead of being put on 'Plugins/Android'.

If all of the above steps do not work, you should try to change Gradle, in one of my projects Gradle 6.5 is building correctly but 6.1 isn't building.

This process is really messy but in a few days (at maximum) you should be able to get it working, remember to change the Unity version only if it's extremely necessary, else the problems will be more than the benefits.

Upvotes: 1

Related Questions