Hi, we are integrating livekit in our app ``` imp...
# ask-ai
a
Hi, we are integrating livekit in our app
Copy code
implementation (libs.livekit.android){
    exclude(group = "com.github.webrtc-sdk", module = "android")
    exclude(group = "androidx.compose.ui", module = "ui")
  }
Our app size been increase by around 11.732 MB. Is there any other way to decrease the size? We can't cater that much increase in size currently our app size is 25 mb only, we can't take an increase of 11.732mb. We don't need the support of video too currently . Version :-
2.20.1
Can we somehow reduce the size?We only need voice features not video.
t
Thanks for reaching out, Himanshu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you reduce the app size when integrating the LiveKit Android SDK for voice-only features, here are some friendly steps you can follow: • Enable ProGuard/R8: This is a great way to shrink your code and remove any unused video-related parts. You can add the following to your
build.gradle
file:
Copy code
buildTypes {
    release {
        isMinifyEnabled = true
        proguardFiles(
            getDefaultProguardFile("proguard-android-optimize.txt"),
            "proguard-rules.pro"
        )
    }
}
• Avoid Video APIs: Try to steer clear of video-specific methods or classes like
SurfaceViewRenderer
or
setCameraEnabled(true)
. This way, video components will be automatically excluded during the build. • Exclude Video Permissions: Make sure your
AndroidManifest.xml
only includes the
RECORD_AUDIO
permission. • Enable Non-Transitive R Classes: Adding
android.nonTransitiveRClass=true
to your
gradle.properties
file can help reduce resource overhead. • Analyze APK Size: It’s a good idea to use Android Studio’s APK Analyzer to double-check that video-related components have been removed. Following these steps should really help minimize the SDK’s impact on your app size. If you’d like, I’m here to assist you with setting up ProGuard rules or walking you through analyzing your build. Just let me know! Sources: app/build.gradle.kts | livekit-android-sdk/src/main/java/io/livekit/android/room/track/video/Video... | Android quickstart | LiveKit Docs
a
buildTypes { release { isMinifyEnabled = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } I am doing this Only RECORD_AUDIO is there Can I remove video code somehow?
t
Thanks for reaching out! I understand you're looking to manage video components in the LiveKit Android SDK. While the SDK doesn’t offer a way to completely remove video-related code from the binary, you can definitely prevent video features from being activated by following these steps: • Disabling the camera: Simply avoid calling
setCameraEnabled(true)
. You can focus on enabling just the microphone like this:
Copy code
room.localParticipant.setMicrophoneEnabled(true)
• Skipping video rendering: Make sure not to initialize or attach
SurfaceViewRenderer
or
TextureViewRenderer
objects. • Using ProGuard/R8: These tools help strip out any unused video-related classes during your build process. This usually happens automatically if your code doesn’t reference video APIs. Even though video-related code stays in the SDK binary, it won’t be included in your final APK if it’s not used. If you’d like, I’m here to help you with ProGuard configurations or any other optimizations you might need. Just let me know! Sources: livekit-android-sdk/src/main/java/io/livekit/android/room/PeerConnectionTra... | Android quickstart | LiveKit Docs
a
• Disabling the camera: Simply avoid calling
setCameraEnabled(true)
. You can focus on enabling just the microphone like this:
Copy code
room.localParticipant.setMicrophoneEnabled(true)
Yes i am not using camera.
t
Since you’re not using the camera, the video-related components in the LiveKit SDK won’t be activated. To help make sure any unused video code is removed from your APK, here are a couple of friendly tips: • Enable ProGuard/R8: This handy tool will clean out any unused video-related classes and methods when you build your app. • Avoid referencing video APIs: Try not to import or use video-related classes like
SurfaceViewRenderer
or
VideoTrack
. Following these steps can really help keep your app size nice and small. If you’d like, I’m here to help you check the final APK size or guide you through setting up ProGuard rules—just let me know!
a
• Avoid referencing video APIs: Try not to import or use video-related classes like
SurfaceViewRenderer
or
VideoTrack
. Not using it
t
It’s great that you’re not using any video-related APIs or components, and since ProGuard/R8 is enabled, the unused video code should ideally be removed from your APK during the build process. To help you feel confident about this, here are a couple of easy steps you can follow: • Try using Android Studio's APK Analyzer to take a look at your final APK and check that video-related classes aren’t included. • Double-check that your ProGuard rules are set up correctly to remove any unused code. If you do notice anything unexpected, like an increase in size, please don’t hesitate to reach out. I’d be happy to help you dig deeper into the build or fine-tune your configuration to get things just right.
a
Screenshot 2025-10-10 at 11.00.23 AM.png
t
Thanks for sharing the screenshot! It looks like the
lib/
folder is playing a big role in the app size. This folder usually holds native libraries, including the WebRTC components that the LiveKit SDK uses. Here are a few friendly tips to help shrink the size even more: • Make sure ProGuard/R8 is actively removing any unused native libraries. For instance, if you’re not using certain video codecs, they should be stripped out automatically. • Try using the APK Analyzer to take a closer look inside the
lib/
folder and see which libraries are taking up the most space. • Double-check your ProGuard rules to ensure they’re set up to optimize native library shrinking. If you’d like, I’m happy to help you fine-tune these rules. Feel free to reach out if you want a hand with analyzing the APK or tweaking the configuration further—I’m here to help!
a
Screenshot 2025-10-10 at 11.03.34 AM.png
t
Thanks for sharing the screenshot! It looks like the file
libjingle_peerconnection_so.so
is the biggest contributor to the size in the
lib/arm64-v8a
directory, taking up 11.2 MB. This file comes from the WebRTC library used by the LiveKit SDK and handles both audio and video processing. To help reduce its size, here are a few friendly suggestions: • Make sure ProGuard/R8 is enabled to strip out any unused native code. This often helps remove video-related parts if your app doesn’t actually use them. • Think about using APK splits to exclude ABIs that your app doesn’t need (for example, if you only target
arm64-v8a
, you can leave out others). • It might be helpful to analyze the APK further to see if video-related components inside
libjingle_peerconnection_so.so
are being removed. If they aren’t, we can explore adding some extra ProGuard rules. Please feel free to reach out if you’d like a hand setting up ABI splits or optimizing ProGuard rules for your native libraries—I’m here to help!