Search Unity

iOS build loads assembly from Assets/Plugins/Android. Why? Build fails.

Discussion in 'iOS and tvOS' started by ChimeraIT, Apr 22, 2015.

  1. ChimeraIT

    ChimeraIT

    Joined:
    May 9, 2014
    Posts:
    25
    I have difficulties understanding the behaviour of the special "Assets\Plugins" folder, described here: http://docs.unity3d.com/Manual/SpecialFolders.html

    Using Unity 4.6.4p3:

    I have this folder structure, containing managed dlls:

    Assets/Plugins/WP8/WP8Plugin.dll
    Assets/Plugins/Android/AndroidPlugin.dll
    Assets/Plugins/iOS/iOSPlugin.dll


    If I now build an iOS project, I see the expected log output for WP8

    ...Ignoring platform specific dll: Assets/Plugins/WP8/WP8Plugin.dll

    I'd expect that the same line would appear for Android, but it doesn't.

    Instead, the AndroidPlugin.dll gets referenced. From the log:

    19:35:24 Mono dependencies included in the build
    19:35:24 Dependency assembly - Mono.Security.dll
    19:35:24 Dependency assembly - System.Core.dll
    19:35:24 Dependency assembly - System.Xml.dll
    19:35:24 Dependency assembly - System.dll
    19:35:24 Dependency assembly - mscorlib.dll
    19:35:24 Dependency assembly - UnityEngine.UI.dll
    19:35:25 Dependency assembly - AndroidPlugin.dll
    19:35:25 Dependency assembly - iOSPlugin.dll
    19:35:25 Dependency assembly - Assembly-CSharp.dll


    Along with the iOSPlugin.dll, which I'd expect, as it resides in Assets\Plugins\iOS.

    Now the problem is, if I don't have assembly stripping enabled, the build will fail, because I'm referencing AndroidJavaClass in my AndroidPlugin.dll.

    The log error for the failed build is:

    Mono Ahead of Time compiler - compiling assembly /project/ClientUnity/Temp/StagingArea/Data/Managed/AndroidPlugin.dll
    Missing method CallStatic in assembly /project/ClientUnity/Temp/StagingArea/Data/Managed/AndroidPlugin.dll, type UnityEngine.AndroidJavaObject
    The class UnityEngine.AndroidJavaObject could not be loaded, used in Android

    stderr:

    at UnityEditor.MonoProcessUtility.RunMonoProcess (System.Diagnostics.Process process, System.String name, System.String resultingFile) [0x00000] in <filename unknown>:0
    at UnityEditor.MonoCrossCompile.CrossCompileAOT (BuildTarget target, System.String crossCompilerAbsolutePath, System.String assembliesAbsoluteDirectory, CrossCompileOptions crossCompileOptions, System.String input, System.String output, System.String additionalOptions) [0x00000] in <filename unknown>:0
    at UnityEditor.MonoCrossCompile+JobCompileAOT.ThreadPoolCallback (System.Object threadContext) [0x00000] in <filename unknown>:0
    UnityEngine.Debug:Internal_Log(Int32, String, Object)
    UnityEngine.Debug:LogError(Object)
    UnityEditor.MonoCrossCompile:CrossCompileAOTDirectoryParallel(String, BuildTarget, CrossCompileOptions, String, String, String)
    UnityEditor.iOS.PostProcessiPhonePlayer:postProcess(iOSBuildPostprocessor, BuildTarget, String, String, String, String, String, String, String, BuildOptions, RuntimeClassRegistry)
    UnityEditor.iOS.iOSBuildPostprocessor:postProcess(BuildPostProcessArgs)
    UnityEditor.PostprocessBuildPlayer:postprocess(BuildTarget, String, String, String, Int32, Int32, String, String, BuildOptions, RuntimeClassRegistry)
    UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, BuildTarget, BuildOptions, Boolean, UInt32&)
    UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, BuildTarget, BuildOptions, UInt32&)
    UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)


    Question: Why is Assets\Plugins\AndroidPlugin.dll referenced at all when building for the iOS platform? Shouldn't it behave like the WP8Plugin.dll, which gets correctly ignored?
     
    Last edited: Apr 22, 2015
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
  3. ChimeraIT

    ChimeraIT

    Joined:
    May 9, 2014
    Posts:
    25
    Ok, thanks for your answer.

    For versions prior to Unity 5, which best practice would you recommend to overcome this? Prebuild-Jobs which delete, for instance, Android plugins for iOS build?

    Is there some really lightweight solution to mitigate that on Unity 4x?

    (I was already trying to manipulate the mono response files (.rsp) in our CI process to remove the reference to the Android assemblies, but that's getting hacky...)
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    Hmph, well probably the easiest way would be:
    • Write an editor function which builds to iOS
      • Rename/Move Android plugin somewhere
      • Call AssetDatabase.Refresh();
      • BuildPipeline.BuildPlayer(<iOS>)
      • Revert back Android plugin
      • Call AssetDatabase.Refresh();
     
  5. ChimeraIT

    ChimeraIT

    Joined:
    May 9, 2014
    Posts:
    25
    Okay, yes, that's what I thought, thanks.