But Unity won’t BUILD the Android project, giving me this:
'MovieTexture' is not supported when building for Android.
Asset: 'Assets/Resources/SSSuccess.mp4'
UnityEditor.HostView:OnGUI()
I tried putting it in StreamingAssets and got the same problem. Note this is at BUILD time, not compile time. I’m not trying to code a MovieTexture. I just have it lying around.
Found it, but leaving this here in case anyone else runs into this: I had assigned the movie to a texture (for web/pc builds). So I had to set that texture to ‘none’.
// Wait for download to complete
yield return www;
// Load and retrieve the AssetBundle
AssetBundle bundle = www.assetBundle;
// Load the TextAsset object
TextAsset txt = bundle.Load("myBinaryAsText", typeof(TextAsset)) as TextAsset;
// Retrieve the binary data as an array of bytes
byte[] bytes = txt.bytes;
In order to support both Windows and Android I had to do the following:
1 Use Platform Dependent Compilation to remove references to MovieTexture
#if UNITY_ANDROID && !UNITY_EDITOR
// Android Code
public string movieString;
#else
// Windows Code
public MovieTexture movieTexture;
#endif
Or
#if UNITY_STANDALONE || UNITY_EDITOR
// Windows Code
public MovieTexture movieTexture;
#endif
2 Make sure that there are no references to any MovieTextures in any fields including Materials.
3 I need to load my MovieTextures dynamically at runtime on Windows so I keep them in the Assets/Resources folder. This is an issue for Android builds because the contents of Resources gets copied to whatever build even if the build can’t support the contents. In order to overcome this I use a build script to build my project which temporarily moves the Resources folder when building for Android.
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.IO;
using System.Collections;
public class Build: MonoBehaviour
{
#if UNITY_EDITOR
// Build Android
// % (ctrl on Windows, cmd on OS X), # (shift), & (alt)
[MenuItem("Build/Build Android %&#b")]
static void BuildAndroid()
{
//_________________________________________
// Pre Build
// Move Resources to a dummy folder
// FIXME: Check if these folders exist
string moveResourcesAway = AssetDatabase.MoveAsset("Assets/Resources", "Assets/StandaloneResources");
Debug.Log(moveResourcesAway);
//_________________________________________
// Build
string[] levels = null; // { "Assets/Scene1.unity", "Assets/Scene2.unity" };
BuildOptions buildOptions = BuildOptions.AutoRunPlayer;
BuildPipeline.BuildPlayer(levels, "Build/BuildAndroid.apk", BuildTarget.Android, buildOptions);
//_________________________________________
// Post Build
// Move Resources back
string moveResourcesBack = AssetDatabase.MoveAsset("Assets/StandaloneResources", "Assets/Resources");
Debug.Log(moveResourcesBack);
}
#endif
}
Not sure if this is the same as other answers given here or not, but I managed to fix this error by altering the Importer Version setting on my file. I changed it from MovieTexture to VideoClip. I.e.: