bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
741 stars 176 forks source link

amr and x86 files make the apk too large #10

Closed EternalSoySauce closed 6 years ago

EternalSoySauce commented 6 years ago

well, ffmpeg needs arm and x86 to support multiple phones, but the files are too large. It builds apk more than 30M. If I delete the files, the apk becomes 2.1M. How can I sovle this problem?

Brianvdb commented 6 years ago

You have to build an APK for each architecture and exlude the unnecessary files for each architecture.

You can accomplish this with productFlavors. Checkout this gradle sample:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27

    defaultConfig {
        applicationId "nl.bravobit.ffmpeg.test"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.1"
    }

    flavorDimensions "abi"

    productFlavors {
        x86 {
            dimension "abi"
            versionCode 1001 // you need different version codes to support multiple APK's in Play Store
            ndk {
                abiFilter "x86"
            }
            aaptOptions {
                ignoreAssetsPattern "!arm"
            }
        }
        armv7a {
            dimension "abi"
            versionCode 2001 // you need different version codes to support multiple APK's in Play Store
            ndk {
                abiFilter "armeabi-v7a"
            }
            aaptOptions {
                ignoreAssetsPattern "!x86"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'

    implementation 'nl.bravobit:android-ffmpeg:1.1.0'
}
EternalSoySauce commented 6 years ago

thx, I'll try it. Happy new year, bro. (^_^)