Unity Android -> ADT (Eclipse) Assets are corrupted ?

When exporting an Eclipse layered project from Unity (v4.0.1) of my game I get some strange bugs that don’t happen in the editor that make the game unplayable. (animations don’t advance, neither does gameplay etc.).

I checked the logcat and the most serious error that I can see is something like as follows :

03-12 11:59:58.170: E/Unity(20839): The file ‘/data/app/com.acompany.agame-2.apk/assets/bin/Data/sharedassets0.assets’ is corrupted! Remove it and launch unity again!
03-12 11:59:58.170: E/Unity(20839): [Position out of bounds! 120381268 > 116722232]
03-12 11:59:58.170: E/Unity(20839):
03-12 11:59:58.170: E/Unity(20839): (Filename: Runtime/Serialize/CacheWrap.cpp Line: 269)
03-12 11:59:58.175: E/Unity(20839): Mismatched serialization in the builtin class ‘AudioClip’. (Read 52 bytes but expected 56 bytes)
03-12 11:59:58.175: E/Unity(20839):
03-12 11:59:58.175: E/Unity(20839): (Filename: Runtime/Serialize/SerializedFile.cpp Line: 1148)
03-12 11:59:59.135: E/Unity(20839): The file ‘/data/app/com.acompany.agame-2.apk/assets/bin/Data/sharedassets0.assets’ is corrupted! Remove it and launch unity again!
03-12 11:59:59.135: E/Unity(20839): [Position out of bounds! 118433732 > 117002376]
03-12 11:59:59.135: E/Unity(20839):
03-12 11:59:59.135: E/Unity(20839): (Filename: Runtime/Serialize/CacheWrap.cpp Line: 269)
03-12 11:59:59.135: E/Unity(20839): Mismatched serialization in the builtin class ‘AudioClip’. (Read 44 bytes but expected 48 bytes)
03-12 11:59:59.135: E/Unity(20839):
03-12 11:59:59.135: E/Unity(20839): (Filename: Runtime/Serialize/SerializedFile.cpp Line: 1148)

Anybody had similar problems ? Why would assets get corrupted like this ?

Following on from this error, I then get the side-effect :

03-12 16:54:39.380: W/Unity(4283): Audio could not be started!
03-12 16:54:39.380: W/Unity(4283):
03-12 16:54:39.380: W/Unity(4283): (Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 43)

Following on from this. I have some success with Unity 4.0.1 and the export of an Eclipse project → imported into ADT as follows (I’m including these exact steps because I couldn’t find exact instructions myself) :

  • From Build Settings dialog in Unity select ‘Create Eclipse project Layer’ and then export somewhere away from the ADT workspace.
  • Open ADT and select Import → ‘Existing projects into workspace’ WITHOUT copying the files to the workspace. [Note : I assume copying into workspace doesn’t work because of a relative path or Symlink issue…guess].
  • Right-click on your project and select Run As->Android Application.

The corruption problem that I had above went away when I decompressed all of the audio files into memory but I’ll have to try compressing again because that is too much.

From experience, what are the best practises for Android audio settings ? Assuming the game will only run on more capable devices (512mb RAM+).

This is usually because of naming conflicts, so if you have a script called Blah.js and a script called Blah.cs in the same project directory it’ll do this when you build. Look for imported script packs or old scripts hanging around. Good luck!