On PC, Application.streamingAssetsPath will be something like:
C:\Program Files (x86)\Steam\steamapps\common\GameName\GameName_Data\StreamingAssets
On Android, when I use Build And Run onto my stock Pixel 3, Application.streamingAssetsPath is:
jar:file:///data/app/~~twQzWYXhkTFpnqzrD8Yrug==/com.NorthwayGames.GameName-YpsXk6xdBgfVaP3D5XRwzw==/base.apk!/assets
And Application.dataPath is:
/data/app/~~twQzWYXhkTFpnqzrD8Yrug==/com.NorthwayGames.GameName-YpsXk6xdBgfVaP3D5XRwzw==/base.apk
Neither of these folders is accessible; Directory.Exists fails and my game breaks. The random character strings are different every time I hit Build And Run.
If I immediately hit Patch and Run without changing any code, Application.streamingAssetsPath is:
file:///data/data/com.NorthwayGames.GameName/pram-shadow-files/assets
Directory.Exists also fails with this folder, until I strip the “file://” from the front.
This streaming assets path DOES work, I can load my files and run my game:
/data/data/com.NorthwayGames.GameName/pram-shadow-files/assets
If I hardcode “/data/data/com.NorthwayGames.GameName/pram-shadow-files”, all builds work regardless of what Application.dataPath or Application.streamingAssetsPath returns. But I obviously can’t do that because the real location may be different for every device.
What’s going wrong here? Is this a problem with the build, or with the deployment, or what? How am I supposed to load a file from streaming assets on Android?