Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

ProGuard Configuration

Taner Sener edited this page Aug 30, 2019 · 5 revisions

MobileFFmpeg archives (.aar files) include their own proguard-rules.pro configuration file inside since v4.2.2 (and v4.2.2.LTS). You don't have to do anything to enable ProGuard on them.

On older versions, please add the following rules inside your application's proguard-rules.pro file to preserve necessary method names and prevent linking errors.

-keep class com.arthenica.mobileffmpeg.Config {
    native <methods>;
    void log(int, byte[]);
    void statistics(int, float, float, long , int, double, double);
}

-keep class com.arthenica.mobileffmpeg.AbiDetect {
    native <methods>;
}

If this rule is not used, ProGuard will obfuscate all MobileFFmpeg methods and your application will fail with the following error on startup.

I/mobile-ffmpeg: Loading mobile-ffmpeg.
CheckJNI: method to register "disableNativeRedirection" not in the given class. This is slow, consider changing your RegisterNatives calls.
Failed to register native method com.arthenica.mobileffmpeg.Config.disableNativeRedirection()V in /data/app/com.arthenica.mobileffmpeg.test-1/split_lib_dependencies_apk.apk:classes14.dex
----- class 'Lcom/arthenica/mobileffmpeg/Config;' cl=0x12c68c10 -----
  objectSize=453 (432 from super)
  access=0x0008.0001
  super='java.lang.Class<java.lang.Object>' (cl=0x0)
  vtable (0 entries, 11 in super):
  direct methods (15 entries):
     0: void com.arthenica.mobileffmpeg.Config.<clinit>()
     1: void com.arthenica.mobileffmpeg.Config.<init>()
     2: void com.arthenica.mobileffmpeg.Config.enableLogCallback(com.arthenica.mobileffmpeg.LogCallback)
     3: void com.arthenica.mobileffmpeg.Config.enableNativeRedirection()
     4: void com.arthenica.mobileffmpeg.Config.enableRedirection()
     5: void com.arthenica.mobileffmpeg.Config.enableStatisticsCallback(com.arthenica.mobileffmpeg.StatisticsCallback)
     6: java.lang.String com.arthenica.mobileffmpeg.Config.getNativeBuildConf()
     7: int com.arthenica.mobileffmpeg.Config.getNativeLogLevel()
     8: java.lang.String com.arthenica.mobileffmpeg.Config.getNativeVersion()
     9: java.lang.String com.arthenica.mobileffmpeg.Config.getPackageName()
    10: void com.arthenica.mobileffmpeg.Config.nativeCancel()
    11: int com.arthenica.mobileffmpeg.Config.nativeExecute(java.lang.String[])
    12: void com.arthenica.mobileffmpeg.Config.resetStatistics()
    13: void com.arthenica.mobileffmpeg.Config.setFontDirectory(android.content.Context, java.lang.String, java.util.Map)
    14: void com.arthenica.mobileffmpeg.Config.setFontconfigConfigurationPath(java.lang.String)
  static fields (6 entries):
     0: com.arthenica.mobileffmpeg.Level com.arthenica.mobileffmpeg.Config.activeLogLevel
     1: com.arthenica.mobileffmpeg.Statistics com.arthenica.mobileffmpeg.Config.lastReceivedStatistics
     2: com.arthenica.mobileffmpeg.LogCallback com.arthenica.mobileffmpeg.Config.logCallbackFunction
     3: boolean com.arthenica.mobileffmpeg.Config.runningSystemCommand
     4: com.arthenica.mobileffmpeg.StatisticsCallback com.arthenica.mobileffmpeg.Config.statisticsCallbackFunction
     5: java.util.concurrent.atomic.AtomicReference com.arthenica.mobileffmpeg.Config.systemCommandOutputReference
E/mobile-ffmpeg: OnLoad failed to RegisterNatives for class com/arthenica/mobileffmpeg/Config.
A/art: art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.NoSuchMethodError: no static or non-static method "Lcom/arthenica/mobileffmpeg/Config;.disableNativeRedirection()V"
Clone this wiki locally