se-bastiaan / TorrentStream-Android

A torrent streamer library for Android based on libtorrent4j
Other
343 stars 108 forks source link

Proguard rule for java.lang.NoSuchMethodError: no static method "Lcom/frostwire/jlibtorrent/swig/libtorrent_jni;.SwigDirector_alert_notify_callback_on_alert(Lcom/frostwire/jlibtorrent/swig/alert_notify_callback;)V #51

Closed sevar83 closed 5 years ago

sevar83 commented 5 years ago

Just to report for anyone who might struggle with ProGuard/R8 that the error:

java.lang.NoSuchMethodError: no static method "Lcom/frostwire/jlibtorrent/swig/libtorrent_jni;.SwigDirector_alert_notify_callback_on_alert(Lcom/frostwire/jlibtorrent/swig/alert_notify_callback;)V" at com.frostwire.jlibtorrent.swig.libtorrent_jni.swig_module_init(Native Method) at com.frostwire.jlibtorrent.swig.libtorrent_jni.(Unknown Source:48) at com.frostwire.jlibtorrent.swig.libtorrent_jni.alert_error_notification_get(Native Method) at com.frostwire.jlibtorrent.swig.h.(Unknown Source:2) at d.g.a.a.d.(Unknown Source:2) at d.g.a.m.(Unknown Source:11) at d.h.b.a.j.run(Unknown Source:2) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.os.HandlerThread.run(HandlerThread.java:65)

can be easily fixed with the following rules:

-keep class com.frostwire.jlibtorrent.swig.libtorrent_jni {*;}
-keep class com.frostwire.jlibtorrent.swig.** { *; }

@se-bastiaan, you might wish to add those lines in the README or even as a consumerProguardFiles in library/build.gradle.

sevar83 commented 5 years ago

After some discusion with the Google support at https://issuetracker.google.com/issues/127905310 we finally came up with these 2 rules:

-keepclasseswithmembernames,includedescriptorclasses class com.frostwire.jlibtorrent.swig.libtorrent_jni {
  native <methods>;
}
-keep class com.frostwire.jlibtorrent.swig.** { *; }