Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive APK Size When Including Banuba Video SDK in Flutter App #2

Open
Logoutbye opened this issue Jul 9, 2024 · 1 comment
Open

Comments

@Logoutbye
Copy link

I am experiencing a significant increase in APK size when integrating the Banuba Video SDK into my Flutter app. The release APK size without the SDK is around 30 MB, but it balloons to over 600 MB when the SDK is included.

Steps to Reproduce:

Create a new Flutter project.
Integrate the Banuba Video SDK according to the official documentation.
Build the release APK using flutter build apk.
Expected Behavior:

The APK size should increase moderately and stay within a reasonable range.

Actual Behavior:

The APK size increases to over 600 MB, which is not practical for distribution.

ProGuard Configuration:

Here is my current ProGuard configuration:

Preserve BouncyCastle classes

-keep class org.bouncycastle.** { *; }

Preserve Conscrypt classes

-keep class org.conscrypt.** { *; }

Preserve OpenJSSE classes

-keep class org.openjsse.** { *; }

Prevent obfuscation of classes needed by OkHttp

-keepattributes Signature
-keepattributes Annotation
-dontwarn javax.annotation.**
-dontwarn okio.**
-keep class okhttp3.** { ; }
-keep interface okhttp3.
* { ; }
-keep enum okhttp3.
* { ; }
-keep class org.conscrypt.
* { ; }
-keep class org.bouncycastle.
* { ; }
-keep class org.openjsse.
* { *; }

Please add these rules to your existing keep rules in order to suppress warnings.

This is generated automatically by the Android Gradle plugin.

-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE

Build Configuration:

Here is my build.gradle configuration:
{
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "kotlin-parcelize"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

android {
namespace = "com.banuba.ve.sdk.flutter.plugin.ve_sdk_flutter_example"
compileSdkVersion 34

compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
    jvmTarget = '17'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.ke.oneta"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdkVersion 24
    targetSdkVersion 34
    compileSdk 34
    buildToolsVersion "34.0.0"

    versionCode 1
    versionName '1.0'

    ndk {
        abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86-64'
    }
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so flutter run --release works.
        signingConfig signingConfigs.debug
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        
    }
}

}

flutter {
source '../..'
}

dependencies {
}

Flutter Doctor Output:

muhammadbilal@Muhammads-MacBook-Pro ios % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-PK)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.91.0)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!
muhammadbilal@Muhammads-MacBook-Pro ios % flutter build appbundle

@GlebPBanuba
Copy link
Contributor

@Logoutbye
Please check if app:stripReleaseDebugSymbols task completes successfully in Gradle.
Consider disabling x86-64 architecture for prod apk file.
More details https://www.banuba.com/faq/how-to-strip-debug-symbols

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants