Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

[Android] Crashes when proguard is enabled #82

Closed
tonygentilcore opened this issue Feb 13, 2019 · 5 comments
Closed

[Android] Crashes when proguard is enabled #82

tonygentilcore opened this issue Feb 13, 2019 · 5 comments

Comments

@tonygentilcore
Copy link

When proguard is enabled on android the app crashes in JNI_OnLoad of libmobileffmpeg.so. The solution for me was to use a heavy hammer and add the line -keep class com.arthenica.mobileffmpeg.** { *; } to my proguard-rules.pro.

It might be the case that there are more exact rules. This issue is to track that and updating any documentation/examples to be proguard friendly.

@tanersener tanersener self-assigned this Feb 13, 2019
@tanersener tanersener added the question Further information is requested label Feb 13, 2019
@tanersener
Copy link
Owner

Can you please share proguard-rules.pro and build.gradle files used when the crash occurred?

@tonygentilcore
Copy link
Author

proguard-rules.pro was empty and build.gradle had:

  buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }

I realized after filing this that I should have probably filed this under react-native-ffmpeg as that's what I'm using and it seems likely the issue only repros there.

@tanersener
Copy link
Owner

tanersener commented Feb 14, 2019

No problem, it is about mobile-ffmpeg, it should stay here.

Thank you for sharing it. I managed to reproduce it locally, unfortunately crash is there and you're right; a documentation update is needed for that.

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"

@tanersener
Copy link
Owner

Android test-application is updated, on develop branch, to include a proguard enabled release build type. Additionally a new ProGuard Configuration wiki page is added.

tanersener added a commit to tanersener/react-native-ffmpeg-test that referenced this issue Feb 14, 2019
tanersener added a commit to tanersener/flutter-ffmpeg that referenced this issue Feb 14, 2019
@tonygentilcore
Copy link
Author

Thanks! I verified that the tighter rules worked for me.

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

No branches or pull requests

2 participants