For AI agents: see the complete documentation index at /llms.txt.
App size optimization
Updated
Reduce the size of apps that integrate Agora SDK
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Use the Lite SDK
Since version 4.4.0, Agora offers a Lite SDK that provides basic audio and video call functions in a smaller package size. If you only need to implement basic audio and video call functions, integrate the Lite SDK. For details see SDKs.
The Lite SDK includes only the following extensions:
- Video encoding extension
- Video decoding extension
Other extensions and related functions in the Extension list are not supported.
Use the Voice SDK
Video SDK supports both audio and video functions, and the package size is large. If you only need to use audio features, best practice is to integrate the Voice SDK. For details, see Voice SDK Quickstart.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
Remove extensions when integrating manually
When integrating through the Direct download link, manually delete the extension files that you do not need to use.
Remove extensions when integrating using Maven Central
When integrating the Android SDK through Maven Central, you can modify the /Gradle Scripts/build.gradle(Module: <projectname>.app) file to specify the dynamic libraries you need to integrate and exclude extensions you do not need to use. For details on the correspondence between each file in the Android SDK and the fields in dependencies, see implementation fields for details.
Refer to the following samples to include, all, none, or selected extensions.
dependencies {
implementation 'io.agora.rtc:full-sdk:4.0.1'
implementation 'io.agora.rtc:full-screen-sharing:4.0.1'
// ...
}dependencies {
implementation 'io.agora.rtc:full-rtc-basic:4.0.1'
//...
}dependencies {
def agora_sdk_version = "4.3.0"
// The following code contains $, so you must use double-quotes
implementation "io.agora.rtc:full-rtc-basic:\${agora_sdk_version}"
implementation "io.agora.rtc:full-ains:\${agora_sdk_version}"
implementation "io.agora.rtc:audio-beauty:\${agora_sdk_version}"
//...
}Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Use the Lite SDK
Since version 4.4.0, Agora offers a Lite SDK that provides basic audio and video call functions in a smaller package size. If you only need to implement basic audio and video call functions, integrate the Lite SDK. For details see SDKs.
The Lite SDK includes only the following extensions:
- Video encoding extension
- Video decoding extension
Other extensions and related functions in the Extension list are not supported.
Use the Voice SDK
Video SDK supports both audio and video functions, and the package size is large. If you only need to use audio features, best practice is to integrate the Voice SDK. For details, see Voice SDK Quickstart.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
Delete extensions when integrating using CocoaPods
When integrating the iOS or macOS SDK through CocoaPods, use the subspecs field in the Podfile to specify the dynamic libraries you need to integrate. This excludes extensions you do not need. For details about the corresponding relationship between dynamic libraries and subspecs field, see subspecs field.
Refer to the following samples to use all, none, or some extensions:
# platform :ios, '9.0'
target 'Your App' do
pod 'AgoraRtcEngine_iOS', '4.3.1'
end# platform :ios, '9.0'
target 'Your App' do
pod 'AgoraRtcEngine_iOS', '4.3.1', :subspecs => ['RtcBasic']
end# platform :ios, '9.0'
target 'Your App' do
pod 'AgoraRtcEngine_iOS', '4.3.1', :subspecs => ['RtcBasic', 'AINS', 'AudioBeauty']
endWhen using the above pod command, make sure that the SDK version you specify includes the extension you have selected, and that the subspecs field is correct, otherwise a pod installation error is reported. For example, if you use pod 'AgoraRtcEngine_iOS', '4.0.0', :subspecs => ['RtcBasic', 'AgoraRtcAINS'], an error is reported.
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
Delete extensions when integrating using CocoaPods
When integrating the iOS or macOS SDK through CocoaPods, use the subspecs field in the Podfile to specify the dynamic libraries you need to integrate. This excludes extensions you do not need. For details about the corresponding relationship between dynamic libraries and subspecs field, see subspecs field.
Refer to the following samples to use all, none, or some extensions:
# platform :ios, '9.0'
target 'Your App' do
pod 'AgoraRtcEngine_macOS', '4.3.1'
end# platform :ios, '9.0'
target 'Your App' do
pod 'AgoraRtcEngine_macOS', '4.3.1', :subspecs => ['RtcBasic']
end# platform :ios, '9.0'
target 'Your App' do
pod 'AgoraRtcEngine_macOS', '4.3.1', :subspecs => ['RtcBasic', 'AINS', 'AudioBeauty']
endWhen using the above pod command, make sure that the SDK version you specify includes the extension you have selected, and that the subspecs field is correct, otherwise a pod installation error is reported. For example, if you use pod 'AgoraRtcEngine_iOS', '4.0.0', :subspecs => ['RtcBasic', 'AgoraRtcAINS'], an error is reported.
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Reduce the app size
To reduce the app size, implement the following strategies:
Use tree shaking
In versions before v4.19.0, the AgoraRTC module is the entrance to all callable methods in the Web Video SDK. Even if you only use a part of the Video SDK's functionality, you still need to load the complete SDK, which may result in the app containing a lot of unused code.
Starting from version 4.19.0, the Video SDK for Web has integrated tree shaking support. Using tree shaking has the following advantages:
- Only load the SDK features you actually use, unreferenced code is removed during the build process.
- Reduce redundancy between SDK dependencies and your app dependencies.
Starting from version 4.22.0, in addition to the core modules, the SDK also provides multiple independent service modules for optional use, such as media stream relay and live streaming, to meet the needs of different business use-cases.
The optimization effect of tree shaking is currently limited by the SDK architecture. Agora will continue to improve the tree shaking effect in future versions.
To use tree shaking, follow these steps to integrate the SDK:
-
Run the following command to install the latest SDK package using npm:
npm install agora-rtc-sdk-ng -
Import all used methods, enumerations, constants, types, and so on by adding
/esmat the end of the package nameagora-rtc-sdk-ng:// Example of correct reference citation method import { createClient } from "agora-rtc-sdk-ng/esm"; // Import enum import { ConnectionDisconnectedReason } from "agora-rtc-sdk-ng/esm"; // Import constant import { VERSION } from "agora-rtc-sdk-ng/esm"; // Import type import type { ICameraVideoTrack } from "agora-rtc-sdk-ng/esm"; -
Starting from version 4.23.0, you can integrate the functional modules you need as follows:
// Import core module
import { AgoraRTC } from "agora-rtc-sdk-ng/esm";
// Import Plan-B module
import { PlanBConnectionService } from "agora-rtc-sdk-ng/services/planb-connection";
AgoraRTC.use(PlanBConnectionService);// Import core module
import { AgoraRTC } from "agora-rtc-sdk-ng/esm";
// Import real-time moderation (content moderation) module
import { ImageModerationService } from "agora-rtc-sdk-ng/services/image-moderation";
import { ContentInspectService } from "agora-rtc-sdk-ng/services/content-inspect";
AgoraRTC.use(ImageModerationService)
.use(ContentInspectService);// Import core module
import { AgoraRTC } from "agora-rtc-sdk-ng/esm";
// Import cross-channel media relay module
import { ChannelMediaRelayService } from "agora-rtc-sdk-ng/services/channel-media-relay";
AgoraRTC.use(ChannelMediaRelayService);// Import core module
import { AgoraRTC } from "agora-rtc-sdk-ng/esm";
// Import live streaming service module
import { LiveStreamingService } from "agora-rtc-sdk-ng/services/live-streaming";
AgoraRTC.use(LiveStreamingService);Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Frequently asked questions
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
Remove unused extensions
When integrating through the Direct download link, manually delete the extension files that you do not need to use.
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Use the Voice SDK
Video SDK supports both audio and video functions, and the package size is large. If you only need to use audio features, best practice is to integrate the Voice SDK. For details, see Voice SDK Quickstart.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
Remove extensions when integrating manually
When integrating through the Direct download link, manually delete the extension files that you do not need to use.
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
If your target platform is Android, use Gradle's packagingOptions.exclude properties to exclude unnecessary extension dynamic libraries from the final APK or AAR file. Removing these files during the packaging process reduces the app size and improves app performance.
In the build.gradle file in the project root directory, find the android configuration block. Under the module packagingOptions, use the exclude attribute to specify the extension dynamic libraries you want to exclude. Refer to the following example to exclude specific extensions:
android {
// ...
packagingOptions {
// Exclude AI denoise extension for the armeabi-v7a architecture
exclude 'lib/armeabi-v7a/libagora_ai_denoise_extension.so'
// Exclude AI denoise extension for the arm64-v8a architecture
exclude 'lib/arm64-v8a/libagora_ai_denoise_extension.so'
// Exclude spatial audio extension for the armeabi-v7a architecture
exclude 'lib/armeabi-v7a/libagora_spatial_audio_extension.so'
// Exclude spatial audio extension for the arm64-v8a architecture
exclude 'lib/arm64-v8a/libagora_spatial_audio_extension.so'
}
}If your target platform is iOS or macOS, follow these steps to reduce the size of your app:
- Add the following script to the Podfile under the target section for the
agora_rtc_enginedependency. This script marks unnecessary extensions as weak frameworks:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
targets_to_weaklink=['Pods-Runner', "agora_rtc_engine"]
# Add more -weak_framework flags for other unnecessary extensions if needed
frameworks_to_weaklink=["AgoraAiEchoCancellationExtension", "AgoraAiNoiseSuppressionExtension", "AgoraAudioBeautyExtension", "AgoraClearVisionExtension", "AgoraContentInspectExtension", "AgoraDrmLoaderExtension", "AgoraReplayKitExtension", "AgoraSpatialAudioExtension ", "AgoraSuperResolutionExtension", "AgoraVideoQualityAnalyzerExtension", "AgoraVideoSegmentationExtension"]
next unless targets_to_weaklink.include?(target.name)
target.build_configurations.each do |config|
base_config_reference = config.base_configuration_reference
unless base_config_reference. nil?
xcconfig_path = base_config_reference.real_path
xcconfig = File.read(xcconfig_path)
frameworks_to_weaklink.each do |framework|
xcconfig = xcconfig.gsub(/-framework "#{framework}"/, "-weak_framework \"#{framework}\"")
end
File.open(xcconfig_path, "w") { |file| file << xcconfig }
end
end
end
end-
To remove unnecessary extensions, follow these steps in Xcode:
-
Navigate to the Build Phases tab.
-
Click the
+button at the bottom left corner of the Build Phases tab and select New Run Script Phase. -
Specify Shell as
/usr/bin/rubyand replace the code part with the following script:
$stderr.puts "Removing Unnecessary Frameworks"
# The extensions listed in frameworks_to_weaklink here should match those in Step 1.
frameworks_to_weaklink=["AgoraAiEchoCancellationExtension", "AgoraAiNoiseSuppressionExtension", "AgoraAudioBeautyExtension", "AgoraClearVisionExtension", "AgoraContentInspectExtension", "AgoraDrmLoaderExtension", "AgoraReplayKitExtension", "AgoraSpatialAudioExtension ", "AgoraSuperResolutionExtension", "AgoraVideoQualityAnalyzerExtension", "AgoraVideoSegmentationExtension"]
for framework in frameworks_to_weaklink
framework_path = "#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['FRAMEWORKS_FOLDER_PATH']}/#{framework}.framework"
`rm -Rf "#{framework_path}"`
endThe following figure shows the required steps:
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
Reducing the app size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the app. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the app. For example, running the app on smart wearable devices with limited storage space.
-
The target user group of the app is located in underdeveloped areas. The poor network connectivity causes the app download time to be too long.
This page shows you how to optimize the size of apps with integrated Video SDK.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
If your target platform is Android, use Gradle's packagingOptions.exclude properties to exclude unnecessary extension dynamic libraries from the final APK or AAR file. Removing these files during the packaging process reduces the app size and improves app performance.
In the build.gradle file in the project root directory, find the android configuration block. Under the module packagingOptions, use the exclude attribute to specify the extension dynamic libraries you want to exclude. Refer to the following example to exclude specific extensions:
android {
// ...
packagingOptions {
// Exclude AI denoise extension for the armeabi-v7a architecture
exclude 'lib/armeabi-v7a/libagora_ai_denoise_extension.so'
// Exclude AI denoise extension for the arm64-v8a architecture
exclude 'lib/arm64-v8a/libagora_ai_denoise_extension.so'
// Exclude spatial audio extension for the armeabi-v7a architecture
exclude 'lib/armeabi-v7a/libagora_spatial_audio_extension.so'
// Exclude spatial audio extension for the arm64-v8a architecture
exclude 'lib/arm64-v8a/libagora_spatial_audio_extension.so'
}
}If your target platform is iOS or macOS, follow these steps to reduce the size of your app:
- Add the following script to the Podfile under the target section for the
agora_rtc_enginedependency. This script marks unnecessary extensions as weak frameworks:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
targets_to_weaklink=['Pods-Runner', "agora_rtc_engine"]
# Add more -weak_framework flags for other unnecessary extensions if needed
frameworks_to_weaklink=["AgoraAiEchoCancellationExtension", "AgoraAiNoiseSuppressionExtension", "AgoraAudioBeautyExtension", "AgoraClearVisionExtension", "AgoraContentInspectExtension", "AgoraDrmLoaderExtension", "AgoraReplayKitExtension", "AgoraSpatialAudioExtension ", "AgoraSuperResolutionExtension", "AgoraVideoQualityAnalyzerExtension", "AgoraVideoSegmentationExtension"]
next unless targets_to_weaklink.include?(target.name)
target.build_configurations.each do |config|
base_config_reference = config.base_configuration_reference
unless base_config_reference. nil?
xcconfig_path = base_config_reference.real_path
xcconfig = File.read(xcconfig_path)
frameworks_to_weaklink.each do |framework|
xcconfig = xcconfig.gsub(/-framework "#{framework}"/, "-weak_framework \"#{framework}\"")
end
File.open(xcconfig_path, "w") { |file| file << xcconfig }
end
end
end
end-
To remove unnecessary extensions, follow these steps in Xcode:
-
Navigate to the Build Phases tab.
-
Click the
+button at the bottom left corner of the Build Phases tab and select New Run Script Phase. -
Specify Shell as
/usr/bin/rubyand replace the code part with the following script:
$stderr.puts "Removing Unnecessary Frameworks"
# The extensions listed in frameworks_to_weaklink here should match those in Step 1.
frameworks_to_weaklink=["AgoraAiEchoCancellationExtension", "AgoraAiNoiseSuppressionExtension", "AgoraAudioBeautyExtension", "AgoraClearVisionExtension", "AgoraContentInspectExtension", "AgoraDrmLoaderExtension", "AgoraReplayKitExtension", "AgoraSpatialAudioExtension ", "AgoraSuperResolutionExtension", "AgoraVideoQualityAnalyzerExtension", "AgoraVideoSegmentationExtension"]
for framework in frameworks_to_weaklink
framework_path = "#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['FRAMEWORKS_FOLDER_PATH']}/#{framework}.framework"
`rm -Rf "#{framework_path}"`
endThe following figure shows the required steps:
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
Reducing the game size is of great significance in improving user experience. A smaller package size means that users consume less bandwidth and time to download the game. Consider the following use-cases where app size optimization is critical:
-
There are strict requirements on the size of the game. For example, running the game on smart wearable devices with limited storage space.
-
The target user group of the game is located in underdeveloped areas. The poor network connectivity causes the game download time to be too long.
This page shows you how to optimize the size of games with integrated Video SDK.
Use the Voice SDK
Video SDK supports both audio and video functions, and the package size is large. If you only need to use audio features, best practice is to integrate the Voice SDK. For details, see Voice SDK Quickstart.
Remove unnecessary extensions
Video SDK provides optional extension dynamic libraries. The name of the extension is suffixed with extension. See the extension list for details on the function and size of the extensions. Refer to the following ways to exclude these extensions to reduce the size of the app.
Open the Assets/Agora-RTC-Plugin/Agora-Unity-RTC-SDK/Plugins folder in Unity Editor. It contains dynamic libraries for iOS, macOS, Windows, and Android. As shown below:
-
Android: If your target platform is Android, consider deleting the following files under the path
Android/AgoraRtcEngineKit.plugin/libs:arm64-v8a/<*>_extension.soarmeabi-v7a/<*>_extension.sox86/<*>_extension.sox86_64/<*>_extension.so
Only delete these files if they are not required for your application to function correctly.
-
iOS: If your target platform is iOS, you can safely delete any unused
<*>Extension.frameworkfiles located in theiOSfolder of your project. -
macOS: For macOS targets, you may delete any unused
<*>Extension.frameworkfiles found in themacOS/AgoraRtcWrapperUnity.bundle/Contents/Frameworkspath. -
Windows: If targeting Windows, you have the option to delete
<*>extension.dllor<*>extension.dll.libfiles located in thex86orx86_64folder.
Exercise caution when deleting files, and always make sure that any removals do not impact the functionality of your application.
Delete files from the exported native project
When exporting a native project from Unity for a target platform, the dynamic library corresponding to that platform is copied to the native project. To remove unnecessary files, delete the dynamic libraries ending with extension directly from the exported native project.
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Extension list
Refer to the following information for an introduction to each Video SDK extension and the increase in the size of your app after integration.
The information in this section is based on version 4.4.0 of the Video SDK.
