Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[SOLVED] Can not build client over CLI

Discussion in 'Package Manager' started by Gardosen, Jan 19, 2021.

  1. Gardosen

    Gardosen

    Joined:
    Oct 25, 2014
    Posts:
    39
    hello,

    i wanted to setup a cli based building system, but sadly i get an error which makes no sense and i hope someone here can help me.

    the command i execute is the following:

    /Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -projectPath "${WORKSPACE}" -executeMethod BuildCommand.BuildiOS -quit -logFile /dev/stdout


    the error i get is the following:
    [Package Manager] An error occurred while resolving packages:
    Project has invalid dependencies:
    com.unity.modules.androidjni: no such package available : com.unity.modules.androidjni
    com.unity.ugui: no such package available : com.unity.ugui


    funny tho in the Unity IDE itself it works flawless. :/
    i have looked trough several of the issue topics here but no solution helped me so far.....

    I hope someone can help me.
     
  2. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    481
    Hi @Gardosen,

    I'm surprised that this isn't working. Can you specify what Unity version you are using? You seemed to have installed the Editor without using the Hub, correct? And lastly, could you please create a Bug Report and attach the generated Editor.log so we can inspect it?
     
  3. Gardosen

    Gardosen

    Joined:
    Oct 25, 2014
    Posts:
    39
    hy @maximeb_unity ,

    here are some details:
    - i have installed 2020.2.1f1 over the Unity_Hub, it is the only version i currently have installed
    - Unity Hub version is Version 2.4.2 (2.4.2)
    - i am running macos big sure 11.1 on a 2019 macbook pro 16 inch
    - i am using a custom script i found in the forum and which i modified a bit so far to serve my need better. i will attach it here
    - if i execute the commands over the Unity IDE everything works fine and the clients are build.
    -- ios can be compiled to an xcode project to be installed on an ipad
    -- macos can be compiled
    -- android can be compiled

    i have checked the Unity Log folder but if i clear everything, the only log which is recreated when i execute my cli command is the upm.log

    Edit 1: i have tested now if this is reproducable and actually it is.
    Step 1: Create a new 3D Project
    Step 2: Copy the BuildCommand.cs to the Editor folder under Assets so it gets loaded by Unity
    Step 3: Close unity and open a terminal
    Step 4: execute the command from below

    Expected Behaviour: The client should build fine
    Actual Behaviour: The Package Manager returns an error related to the ugui and androidjndi package which can not be resolved

    /Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -projectPath "${WORKSPACE}" -executeMethod BuildCommand.BuildiOS -quit -logFile -v /dev/stdout

    Loading GUID <-> Path mappings...0.000047 seconds
    Loading Asset Database...0.012246 seconds
    Audio: FMOD Profiler initialized on port 54900
    AssetDatabase consistency checks...Rebuilding GUID cache ... 0.005254 seconds.
    0.043577 seconds
    Refreshing native plugins compatible for Editor in 22.10 ms, found 1 plugins.
    Preloading 0 native plugins for Editor in 0.00 ms.
    DisplayProgressbar: Unity Package Manager
    [Package Manager] Done resolving packages in 1.13s seconds
    [Package Manager] An error occurred while resolving packages:
    Project has invalid dependencies:
    com.unity.2d.sprite: no such package available : com.unity.2d.sprite
    com.unity.2d.tilemap: no such package available : com.unity.2d.tilemap
    com.unity.modules.androidjni: no such package available : com.unity.modules.androidjni
    com.unity.ugui: no such package available : com.unity.ugui
    A re-import of the project may be required to fix the issue or a manual modification of /Users/marco/Projects/XXXX/XXXX/Packages/manifest.json file.
    [Package Manager] Server::Kill -- Server was shutdown

    {"level":"info","message":"Starting Server","timestamp":"2021-01-19T22:01:37.015Z"}
    {"level":"info","message":"Health Request received","timestamp":"2021-01-19T22:01:37.119Z"}
    {"level":"warn","message":"Package folder [/Applications/Unity/Unity.app/Contents/Resources/PackageManager/Editor/Packman_Temp] missing package manifest.","timestamp":"2021-01-19T22:01:37.233Z"}

    the editor plugin which i am using and which i refed via "-executeMethod BuildCommand.BuildiOS"
    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. using System.IO;
    4. using UnityEditor;
    5.  
    6. public class BuildCommand : MonoBehaviour
    7. {
    8.     private const string ANDROID_KEYSTORE_PASS = "";
    9.     private const string ANDROID_KEYALIAS_NAME = "";
    10.     private const string ANDROID_KEYALIAS_PASS = "";
    11.  
    12.     private static readonly BuildTarget[] TargetToBuildAll =
    13.     {
    14.         BuildTarget.Android,
    15.         BuildTarget.iOS,
    16.         BuildTarget.StandaloneWindows,
    17.         BuildTarget.StandaloneWindows64,
    18.         BuildTarget.StandaloneOSX
    19.  
    20.     };
    21.  
    22.     public static string ProductName => PlayerSettings.productName;
    23.  
    24.     private static string BuildPathRoot
    25.     {
    26.         get
    27.         {
    28.             string path = $"{Application.dataPath}/../ClientBuilds/";
    29.             if (!Directory.Exists(path))
    30.                 Directory.CreateDirectory(path);
    31.             return path;
    32.         }
    33.     }
    34.  
    35.     private static int AndroidLastBuildVersionCode
    36.     {
    37.         get => PlayerPrefs.GetInt("LastVersionCode", -1);
    38.         set => PlayerPrefs.SetInt("LastVersionCode", value);
    39.     }
    40.  
    41.     private static BuildTargetGroup ConvertBuildTarget(BuildTarget buildTarget)
    42.     {
    43.         switch (buildTarget)
    44.         {
    45.             case BuildTarget.StandaloneOSX:
    46.                 return BuildTargetGroup.Standalone;
    47.             case BuildTarget.iOS:
    48.                 return BuildTargetGroup.iOS;
    49.             case BuildTarget.StandaloneWindows:
    50.             case BuildTarget.StandaloneWindows64:
    51.             case BuildTarget.StandaloneLinux64:
    52.             case BuildTarget.Android:
    53.                 return BuildTargetGroup.Android;
    54.             default:
    55.                 return BuildTargetGroup.Standalone;
    56.         }
    57.     }
    58.  
    59.     private static string GetExtension(BuildTarget buildTarget)
    60.     {
    61.         switch (buildTarget)
    62.         {
    63.             case BuildTarget.StandaloneOSX:
    64.                 return ".app";
    65.             case BuildTarget.StandaloneWindows:
    66.             case BuildTarget.StandaloneWindows64:
    67.                 return ".exe";
    68.             case BuildTarget.iOS:
    69.                 return "";
    70.             case BuildTarget.Android:
    71.                 return ".apk";
    72.             case BuildTarget.StandaloneLinux64:
    73.                 break;
    74.         }
    75.  
    76.         return ".unknown";
    77.     }
    78.  
    79.     private static BuildPlayerOptions GetDefaultPlayerOptions()
    80.     {
    81.         BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    82.  
    83.         List<string> listScenes = new List<string>();
    84.         foreach (var s in EditorBuildSettings.scenes)
    85.         {
    86.             if (s.enabled)
    87.                 listScenes.Add(s.path);
    88.         }
    89.  
    90.         buildPlayerOptions.scenes = listScenes.ToArray();
    91.         buildPlayerOptions.options = BuildOptions.None;
    92.  
    93.         return buildPlayerOptions;
    94.     }
    95.  
    96.     private static void DefaultBuild(BuildTarget buildTarget)
    97.     {
    98.         BuildTargetGroup targetGroup = ConvertBuildTarget(buildTarget);
    99.         string targetFolder = GetFolderByBuildTarget(buildTarget);
    100.  
    101.         string path = $"{BuildPathRoot}{targetFolder}";
    102.  
    103.         string name = ProductName + GetExtension(buildTarget);
    104.  
    105.         string defineSymbole = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
    106.  
    107.         PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole + ";BUILD");
    108.  
    109.         PlayerSettings.Android.keystorePass = ANDROID_KEYSTORE_PASS;
    110.         PlayerSettings.Android.keyaliasName = ANDROID_KEYALIAS_NAME;
    111.         PlayerSettings.Android.keyaliasPass = ANDROID_KEYALIAS_PASS;
    112.  
    113.         BuildPlayerOptions buildPlayerOptions = GetDefaultPlayerOptions();
    114.  
    115.         buildPlayerOptions.locationPathName = Path.Combine(path, name);
    116.         buildPlayerOptions.target = buildTarget;
    117.  
    118.         EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, buildTarget);
    119.  
    120.         string result = buildPlayerOptions.locationPathName + ": " + BuildPipeline.BuildPlayer(buildPlayerOptions);
    121.         Debug.Log(result);
    122.         PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole);
    123.  
    124.         if (buildTarget == BuildTarget.Android)
    125.             AndroidLastBuildVersionCode = PlayerSettings.Android.bundleVersionCode;
    126.  
    127.         EditorUtility.RevealInFinder(path);
    128.     }
    129.  
    130.     private static string GetFolderByBuildTarget(BuildTarget _buildTarget)
    131.     {
    132.         switch (_buildTarget)
    133.         {
    134.             case BuildTarget.Android:
    135.                 return "Android";
    136.             case BuildTarget.iOS:
    137.                 return "iOS";
    138.             case BuildTarget.StandaloneWindows:
    139.             case BuildTarget.StandaloneWindows64:
    140.                 return "Windows";
    141.             case BuildTarget.StandaloneOSX:
    142.                 return "MacOS";
    143.             default:
    144.                 return "garbage"; //should never happen for anything supported
    145.         }
    146.     }
    147.  
    148.     [MenuItem("Build/Single/Build Android")]
    149.     private static void BuildAndroid()
    150.     {
    151.         DefaultBuild(BuildTarget.Android);
    152.     }
    153.  
    154.     [MenuItem("Build/Single/Build Win32")]
    155.     private static void BuildWin32()
    156.     {
    157.         DefaultBuild(BuildTarget.StandaloneWindows);
    158.     }
    159.  
    160.     [MenuItem("Build/Single/Build Win64")]
    161.     private static void BuildWin64()
    162.     {
    163.         DefaultBuild(BuildTarget.StandaloneWindows64);
    164.     }
    165.  
    166.     [MenuItem("Build/Single/Build iOS")]
    167.     private static void BuildiOS()
    168.     {
    169.         DefaultBuild(BuildTarget.iOS);
    170.     }
    171.  
    172.     [MenuItem("Build/Single/Build MacOS")]
    173.     private static void BuildMacOS()
    174.     {
    175.         DefaultBuild(BuildTarget.StandaloneOSX);
    176.     }
    177.  
    178.     [MenuItem("Build/Get Build Number")]
    179.     private static void BuildNumber()
    180.     {
    181.         Debug.Log("Current/Last: " + PlayerSettings.Android.bundleVersionCode + "/" + AndroidLastBuildVersionCode);
    182.     }
    183.  
    184.     [MenuItem("Build/Build Number/Up Build Number")]
    185.     private static void BuildNumberUp()
    186.     {
    187.         PlayerSettings.Android.bundleVersionCode++;
    188.         BuildNumber();
    189.     }
    190.  
    191.     [MenuItem("Build/Build Number/Down Build Number")]
    192.     private static void BuildNumberDown()
    193.     {
    194.         PlayerSettings.Android.bundleVersionCode--;
    195.         BuildNumber();
    196.     }
    197.  
    198.     [MenuItem("Build/Build All")]
    199.     private static void BuildAll()
    200.     {
    201.         foreach (BuildTarget b in TargetToBuildAll)
    202.         {
    203.             DefaultBuild(b);
    204.         }
    205.     }
    206. }
    207.  
     
    Last edited: Jan 19, 2021
  4. Gardosen

    Gardosen

    Joined:
    Oct 25, 2014
    Posts:
    39
    @maximeb_unity

    after a night of sleep i took this again into my hands and checked the fact that you for some reason assumed i do not have installed Unity over the hub. I was abit confused that the path of Unity was not part of the Hub folder under Unity and wiped EVERYTHING away from my macbook related to Unity.

    apparently you were right even tho i do not get how this is even possible as i always had used Unity with the hub since i can think of.
    but based on the things i found, apparently i had a super weird screwup version of unity running which was "apparently" installed by the Hub, into the existing installation directly with a mixup of the 2018 package manager + unity 2020.2.1f1 + temp files of extremly old textmesh packages which in the editor appeared to be as 3.0.3 but where 2.x.x (this might also explain some issues i had with my project recently.

    now i am able to build with the client just fine.
    Problem solved o.o
     
    maximeb_unity likes this.
  5. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    481
    Hey, thanks for letting us know things are fine on your end! :)