Search Unity

Error building android using a custom editor package

Discussion in 'Package Manager' started by robloz, Dec 24, 2018.

  1. robloz

    robloz

    Joined:
    Apr 27, 2013
    Posts:
    10
    I have created an editor custom package which builds a project to android. This package only contains:

    Assets/Editor/BuildAssembly.Editor.asmdef
    Assets/Editor/CustomBuild.cs
    Assets/Editor/MyCustomBuildProcessor.cs


    BuildAssembly.Editor.asmdef:
    Code (JavaScript):
    1.  
    2. {
    3.     "name": "BuildAssembly.Editor",
    4.     "references": [],
    5.     "optionalUnityReferences": [],
    6.     "includePlatforms": [
    7.         "Editor"
    8.     ],
    9.     "excludePlatforms": [],
    10.     "allowUnsafeCode": false,
    11.     "overrideReferences": false,
    12.     "precompiledReferences": [],
    13.     "autoReferenced": true,
    14.     "defineConstraints": []
    15. }
    CustomBuild.cs
    Code (CSharp):
    1.        
    2. public static void BuildAndroid()
    3.         {
    4.             ...........................
    5.             BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    6.             buildPlayerOptions.scenes = collectBuildScenes();
    7.             buildPlayerOptions.locationPathName = filename;
    8.             buildPlayerOptions.target = BuildTarget.Android;
    9.             buildPlayerOptions.options = BuildOptions.None | BuildOptions.ShowBuiltPlayer;
    10.             BuildPipeline.BuildPlayer(buildPlayerOptions);
    11.            ......................
    12.         }

    In other hand, I have another project that uses BuildAndroid method in this way:
    Code (CSharp):
    1.      
    2.     [MenuItem("Project Tools/Build/Android")]
    3.     public static void BuildAndroid()
    4.     {
    5.         Custom.Build.Editor.CustomBuild.BuildAndroid();
    6.     }
    7.  
    Every time I click on that button I get this error:

    ArgumentException: The Assembly UnityEditor is referenced by BuildAssembly.Editor ('Packages/com.custom.build/Library/ScriptAssemblies/BuildAssembly.Editor.dll'). But the dll is not allowed to be included or could not be found.
    UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:155)
    UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:195)
    UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
    Custom.Build.Editor.CustomBuild:BuildAndroid() (at D:/Roberto/Coding/UnityPackages/Build/Assets/Editor/CustomBuild.cs:45)
    ProjectToolMenu:BuildAndroid() (at Assets/Editor/ProjectToolMenu.cs:8)


    It looks like unity is adding my custom package (BuildAssembly.Editor) in production build which it shouldn´t happen as that package is marked
    as "includePlatforms": ["Editor"]

    I am not sure if I am missing something. I also noticed that every time I changed anything in the cs from my custom package,
    I will have to delete library folder and reimport all otherwise I will get this error: error CS1704: An assembly with the same name `BuildAssembly.Editor' has already been imported. Consider removing one of the references or sign the assembly


    Unity version: 2018.2.14f1

    Project: https://drive.google.com/file/d/1tq2Dye7h-qASpupS8hf29GRHu8OSWCJO/view?usp=sharing
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @robloz ,

    I have looked at your project. The custom package you have built includes a full Unity project. This is bound to create problems. I suggest you clean up your package to include only the required assets.

    Regards,

    Pascal