Android Platform
Plugin Specs
- Compatibility
- Unity 2019.x - 2023.x are supported (see below for build notes)
- Supported CPU architectures are arm-v7a, arm64-v8a, x86 and x86-64
- This plugin requires minimum SDK Android 8.0.0 (Oreo, API level 26)
- This plugin requires target SDK Android 12.0.0 (Snow Cone, API level 31)
- Rendering
- OpenGLES 3.0 and Vulkan (Unity 2020 and onwards) are supported
- Multi-threaded rendering is supported
- Internals
- Under the hood we’re using the Android MediaPlayer API and media3-ExoPlayer API
- The only 3rd-party libraries used are:
- media3-ExoPlayer hhttps://github.com/androidx/media
- Facebook Audio 360 1.7.12 https://github.com/facebookarchive/facebook-360-spatial-workstation
- Secret Rabbit Code (aka libsamplerate) 0.1.9 http://www.mega-nerd.com/SRC/license.html
Supported Media
See the Supported Media section for more information.
Streaming
See the Streaming section for more information.
Platform-Specific Options
See the Platform-Specific Options section for more information.
Build Notes
Unity 2023.0 and above
When using Unity 2023.0 and above and you are using 'Application Entry Point' set to 'GameActivity', you will need to perform the following steps to successfully build your project:
- Navigate to
Player Settings|Publisher Settings
, enable theCustom Launcher Gradle Template
option - Open the template file
/Assets/Plugins/Android/launcherTemplate.gradle
- Add
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
to thedependencies
section
Proguard Minify
If you use Android minify options, AVPro Video will be stripped out and will not work. The following options need to be added to your proguard configuration file (in Player Settings > Android > Publishing Settings > Build > Custom Proguard File
) to prevent AVPro Video classes from being removed:
-keep class com.renderheads.AVPro.Video.** { *; }
-keep class androidx.media3.exoplayer.** { *; }
-keep class com.twobigears.audio360.** { *; }
The above is included in /Assets/AVProVideo/Runtime/Plugins/Android/proguard-avprovideo.txt
OES Playback Path
Note
OES playback is not available in the trial version and ONLY supported when using the OpenGLES 3.0 pipeline
For Android there is a special playback option called “Use Fast OES Path”. This option caters especially for VR where users are trying to get the highest possible frame rate and resolution out of the device (without it overheating at the same time). The option is available in the Platform Specific section of the MediaPlayer component:
The OES path is not enabled by default because it requires some special care to be taken and can be tricky for beginners. When this option is enabled the Android GPU returns special OES textures (see EGL extension OES_EGL_image_external) that are hardware specific. Unfortunately Unity isn’t able to use these textures directly, so you can’t just map them to a material or UI. To use the texture a GLSL shader must be used. Unfortunately Unity’s GLSL support isn’t as good as its CG shader support so again this makes things more tricky. The GLSL compiler only happens on the device (not inside Unity) so errors in the shader can be difficult to debug.
We have included a version of the VR sphere shader that supports stereo videos as an example. Hopefully in the future we can improve the integration of these shaders so they aren’t such special cases. This playback path is much faster though, so is definitely worth exploring. Note that for VR stereo rendering, OES only currently supports multi-pass rendering path, and not single-pass or single-pass instanced.
Troubleshooting
Streaming
- If you want to support streaming from URL don’t forget to set the “Internet Access” option in Player Settings to “require”
- If you’re streaming on Android 9 or above and connecting to an HTTP stream, then you either need to switch to HTTPS stream, or enable cleartext support in the AndroidManifest.xml
java.lang.ClassNotFoundException / java.lang.NoSuchMethodError
- Check whether you have Proguard minification enabled (see notes on Minify above) which may be over-optimising and stripping AVPro Video files
- Check the Gradle build notes above
Collecting Logs
- We often need to see the device logs to work out why something isn't working. For this the device should be connected via USB.
- If you're using Android Studio then you can click on the
Logcat
tab and chooseNo Filters
in the bar on the top right. You should see logs being produced and can copy-paste all of them into a text file. - Another useful tool on Windows is called mLogcat and is a GUI tool for monitoring and capturing logs from Android.
- Alternatively the command-line tool "adb logcat" can be used from the Android SDK.