Common issues and solutions for the ApsaraVideo Player SDK for Android.
License-related issues
Resolve invalid or expired license issues in License FAQ.
Common issues across platforms
-
For platform-independent issues, check Cross-platform player FAQs.
-
Experienced developers can also troubleshoot playback errors independently.
Development issues
Get current playback progress
The player SDK reports playback progress every 500 ms by default. Adjust the callback interval as needed:
// Modify the callback interval.
PlayerConfig config = mAliyunLivePlayer.getConfig();
config.mPositionTimerIntervalMs = 100;// The callback interval in ms.
mAliyunLivePlayer.setConfig(config);
mAliPlayer.setOnInfoListener(new IPlayer.OnInfoListener() {
@Override
public void onInfo(InfoBean infoBean) {
if(infoBean.getCode() == InfoCode.CurrentPosition){
// The current playback progress.
long currentPosition = infoBean.getExtraValue();
}
}
});
Get source audio and video data
To retrieve raw audio and video data, switch to software decoding and play an unencrypted video:
// Switch to software decoding.
mAliPlayer.enableHardwareDecoder(false);
IPlayer.RenderFrameCallbackConfig renderFrameCallbackConfig = new IPlayer.RenderFrameCallbackConfig();
// Specifies whether to return only the underlying video data address. Default value: true.
renderFrameCallbackConfig.mVideoDataAddr = false;
// Specifies whether to return only the underlying audio data address. Default value: false.
renderFrameCallbackConfig.mAudioDataAddr = false;
mAliPlayer.setRenderFrameCallbackConfig(renderFrameCallbackConfig);
mAliPlayer.setOnRenderFrameCallback(new IPlayer.OnRenderFrameCallback() {
@Override
public boolean onRenderFrame(FrameInfo frameInfo) {
return false;
}
});
Get the video width and height
Retrieve the video width and height using one of these methods:
-
After the AliPlayer instance enters the `prepared` state:
mAliyunPlayer.setOnPreparedListener(new IPlayer.OnPreparedListener() { @Override public void onPrepared() { mAliyunPlayer.getVideoWidth(); mAliyunPlayer.getVideoHeight(); } }); -
Listen for the video size change callback:
mAliyunPlayer.setOnVideoSizeChangedListener(new IPlayer.OnVideoSizeChangedListener() { @Override public void onVideoSizeChanged(int width, int height) { } }); -
Use the track info:
mAliyunPlayer.setOnTrackReadyListener(new IPlayer.OnTrackReadyListener() { @Override public void onTrackReady(MediaInfo mediaInfo) { List<TrackInfo> trackInfos = mediaInfo.getTrackInfos(); for (TrackInfo trackInfo : trackInfos) { if(trackInfo.getType() == TrackInfo.Type.TYPE_VIDEO){ trackInfo.getVideoWidth(); trackInfo.getVideoHeight(); } } } });
Get pixel data for each video frame
Retrieve pixel data by listening for the OnRenderFrameCallback callback:
player.setOnRenderFrameCallback(frameInfo -> {
if (frameInfo.frameType == FrameInfo.FrameType_video) {
// Video data
} else {
// Audio data
}
return false;
});
Automatic bitrate switching logic
When you call mAliPlayer.selectTrack(TrackInfo.AUTO_SELECT_INDEX) to enable automatic bitrate switching, the player SDK calculates network speed. If the speed sustains the next bitrate level for 10 seconds, the player switches. Otherwise, it stays at the current bitrate.
-
High to low: if the network speed reaches the next bitrate level within 10 seconds, the player finishes cached high-bitrate content before switching.
-
Low to high: the player switches immediately once the speed sustains the higher bitrate for 10 seconds.
To use automatic bitrate switching, transcode the video into an adaptive bitrate stream in the console, then configure the player to retrieve it. Example with VidAuth:
VidAuth vidAuth = new VidAuth();
List<Definition> list = new ArrayList<>();
list.add(Definition.DEFINITION_AUTO);
vidAuth.setDefinition(list);
Custom retry logic
By default, the player SDK retries twice with a 15-second network timeout per attempt. If both retries fail, an `Error` callback fires.
To customize retry logic, set the retry count to 0 and handle retry events externally:
PlayerConfig config = mAliPlayer.getConfig();
// 1. Set the number of retries. In this example, it is set to 0.
config.mNetworkRetryCount = 0;
mAliPlayer.setConfig(config);
mAliPlayer.setOnInfoListener(new IPlayer.OnInfoListener() {
@Override
public void onInfo(InfoBean infoBean) {
// 2. Listen for the retry event.
if(infoBean.getCode() == InfoCode.NetworkRetry){
// TODO: Process the logic as needed.
}
}
});
An unsupported protocol error occurs during ARTC stream playback
Cause 1: The player SDK is integrated, but the bridge layer (AlivcArtc) and the Real-Time Streaming (RTS) component (RtsSDK) are not.
Solution: Integrate the required components. Implement RTS stream pulling on Android.
Cause 2: The version of the bridge layer (AlivcArtc) does not match the player version.
Solution: Ensure the bridge layer (AlivcArtc) and player use the same version. Implement RTS stream pulling on Android.
Cause 3: The RTS component (RtsSDK) is not loaded.
Solution: Load the RTS component (RtsSDK) in the Application file or the target Activity as needed.
static {
System.loadLibrary("RtsSDK");
}
Cause 4: The minSDK version is too high, and the bridge layer (AlivcArtc) is not loaded correctly.
// 1. Modify minSdk
Downgrade minSdk to 21
// 2. Manually load the ARTC library
static {
System.loadLibrary("RtsSDK");
System.loadLibrary("cicada_plugin_artcSource");
}
The progress bar jumps back after a seek operation
Cause: The player uses inaccurate seek by default and starts playback from the nearest keyframe.
Solution: Switch to the accurate seek mode.
How to switch between accurate and inaccurate seek modes
Switch between seek modes:
// Inaccurate seek.
mAliPlayer.seekTo(1000);
mAliPlayer.seekTo(1000, IPlayer.SeekMode.Inaccurate);
// Accurate seek.
mAliPlayer.seekTo(1000,IPlayer.SeekMode.Accurate);
The progress bar still jumps back after switching to the accurate seek mode
Cause: If the distance from the seek point to the nearest keyframe exceeds the maximum accurate seek interval, the player SDK falls back to inaccurate seek, causing the progress bar to jump.
Solution: Increase the maximum accurate seek interval to reduce fallback to inaccurate seek. A longer interval improves accuracy but may increase seek time:
// Unit: ms.
mAliPlayer.setMaxAccurateSeekDelta(10000);
Local cache: Can the cache directory be set to the internal storage directory?
Yes. Set the cache directory to internal storage, but ensure the app has the required access permissions.
An `encrypt check fail` error occurs during video caching
If secure download is enabled, the encryption verification file must match your app information. Download the file from Offline download and save it to the player SDK. Video download. Mismatched files cause caching or download failures.
Playback issues
A crash occurs when creating the player
Troubleshoot the issue as follows:
-
Check whether the CPU architecture is x86.
The player SDK supports only the arm64-v8a and armeabi-v7a architectures. It does not support the x86 architecture.
-
Check whether both the .so files and Maven dependencies for the player SDK are integrated in the project.
For example, you may have integrated the player SDK using a Maven dependency in `build.gradle` and also integrated the player-related dynamic libraries in the `libs` directory of the project's module.
Recommended: Remove the dynamic libraries and use only the Maven dependency. If you must use dynamic libraries, ensure all .so files are from the same version. Integrate the SDK. The following figure shows the player-related dynamic libraries:

-
If you integrated a partial package, confirm that the AlivcFFmpeg version dependency is correct.
For information about AlivcFFmpeg version dependencies, see AlivcFFmpeg version dependencies.
A crash occurs while the player is running
Troubleshoot the issue as follows:
-
Confirm whether the crash occurred in the player SDK.
Check for a crash stack with the
AliyunPlayerprefix. If a stack with this prefix exists, the issue is in the player SDK. -
Upgrade to the latest version of the player SDK and verify whether the issue is fixed.
-
If the issue persists, collect crash files (including all threads), crash logs, and scenario details. How to retrieve issue logs.
Black bars appear during video playback
Troubleshoot the issue as follows:
-
Check whether the source video itself has black bars.
-
You can adjust the player's scaling mode using the following interface.
/* SCALE_ASPECT_FILL: Fills the screen proportionally. The video is cropped. SCALE_ASPECT_FIT: Scales the video proportionally. Black bars may appear. SCALE_TO_FILL: Fills the screen without maintaining proportions. The video is distorted. */ mAliPlayer.setScaleMode(); -
If the scaling mode does not meet your needs, you can adjust the size of the SurfaceView or TextureView at the application layer.
Audio plays but no video appears
Troubleshoot the issue as follows:
-
Play the video with another player to check whether it is an audio-only file.
-
Verify that the display view is correctly configured and not removed from the playback interface. Set the display view as described in Step 4 of Basic features.
An `Invalid argument` error occurs when playing a local video with read permissions
Check the file name and absolute path. Avoid combining Chinese characters and spaces in the path.
A `Permission denied` error occurs when playing a local video with read permissions
On Android 10 (Android Q) or later, add android:requestLegacyExternalStorage="true" to the application tag in AndroidManifest.xml to handle the scoped storage feature.
A `Redirect to a url` error occasionally occurs during video playback
This error may occur due to DNS hijacking. Enable HTTPDNS to resolve it. Configure HTTPDNS for Android.
A black notification bar flashes on notched screens during full-screen playback
You can resolve this by setting an immersive status bar.
Failed to play a MOV video
The player SDK supports MOV videos. Playback may fail if the moov atom is located after the mdat atom in the source file. Transcode the video to move the moov atom before the mdat atom. Step 2: Troubleshoot the stream.
An error occurs during initialization or playback, indicating that the player SDK's .so dynamic library cannot be found
Troubleshoot the issue as follows:
-
Check whether the CPU architecture meets the requirements.
The player SDK supports dynamic libraries for only the arm64-v8a and armeabi-v7a architectures.
-
Check whether the player SDK version is too old.
If you are using player SDK V5.4.6.0-full or earlier, upgrade to V5.4.6.0-full-15467853 or later. Android SDK release notes.
An error occurs when using AliListPlayer to play HLS (m3u8) videos
The list player AliListPlayer supports HLS (m3u8) videos starting from V5.4.5.0, but local caching must be enabled. Local cache.
Does the Android player SDK support playing videos from the assets and raw folders in an Android project?
No. Copy the video to the device storage and use the absolute path for playback.
A 403 error occurs and playback fails after configuring local caching for an HLS video stream
Symptom: When you play an HLS (M3U8) video stream using the VidAuth playback method with local caching enabled, playback fails and a 403 error is reported.
Cause: After local caching is enabled, if you exit playback before the video is fully cached, the uncached portion is requested using the expired VidAuth information from the previous session the next time you start playback. This causes an authentication failure and a 403 error.
Solution: For player SDK V5.5.4.0 and later, if the video playback URL contains authentication parameters and the playback protocol is HLS, you can set the PlayerConfig.mEnableStrictAuthMode field to select a different authentication mode. The default value is `false`.
-
Non-strict authentication (false): Authentication is cached. If only part of the media was cached previously, the player uses the cached authentication for subsequent requests. If URL authentication has a short validity period or playback resumes after a long pause, authentication may expire. Integrate with auto-refresh playback sources to handle authentication expiration.
-
Strict authentication (true): Authentication is not cached. Authentication occurs on every startup, causing startup failure without network.
Does the Android player SDK support play-while-downloading?
No. The player SDK caches and downloads video files during playback when local caching is enabled. Cached files play directly on subsequent playback. Moving cached files from their original directory is not supported.
Does the Android player SDK support getting the buffering speed of a video?
Yes. The player SDK provides buffering speed, real-time rendering frame rate, audio and video bitrates, and network download bitrate. Get playback information.
Abnormal HDR video playback
The player SDK does not currently support HDR videos with rotation angles. Playback errors may occur for these videos.
If a video is transcoded into multiple definitions, which definition does the player SDK play by default?
The default playback order is FD, LD, SD, HD, 2K, 4K, OD. Definition. The player SDK plays the first available definition in this order.
How to specify the default playback definition
Example:
// The VidSts playback method is used as an example.
VidSts vidSts = new VidSts();
// The code for setting parameters such as vid, AccessKeyId, AccessKeySecret, and token is omitted. For more information, see the player creation settings in the Basic Features topic.
/*
Parameter 1: The desired playback definition. Valid values: FD, LD, SD, HD, 2K, 4K, and OD.
Parameter 2: Specifies whether to enforce playback of the desired definition. false: Does not enforce playback of the desired definition. The player SDK searches for a definition to play based on the default order. true: Enforces playback of the desired definition. If the desired definition is not found, the video is not played.
*/
vidSts.setQuality("",false);
If a definition has multiple streams, which stream does the player SDK play?
If a definition has multiple streams, the player SDK plays the latest stream.
Other issues
How to play a video without a watermark but download it with a watermark
Transcode the video into multiple definitions. Play the definition without a watermark and download the definition with a watermark.
How to get issue logs
Submit issue logs to help Alibaba Cloud technical support resolve your problem faster.
-
Retrieve the issue logs.
Set the log level to
AF_LOG_LEVEL_TRACEbefore collecting logs. Get SDK logs. -
Provide the generated logs to Alibaba Cloud technical support.