Closed e4basil closed 6 years ago
Hi @e4basil, I notice that you are using another project (org.proninyaroslav.libretorrent
), this looks like a missing dependency, can you post your gradle dependencies?
This happened when it enabled option minifyEnabled
, please see https://github.com/proninyaroslav/libretorrent/issues/157.
right, well, this goes to the core of how JNI and SWIG
works together, but it's very easy to solve. You just need to be sure to keep all the native methods declaration. Since they are all native, stripping them gains nothing (or very little) to you, all the actual code still remains in the native library. Modify your proguard rules files with the following line:
-keep class com.frostwire.jlibtorrent.swig.libtorrent_jni {*;}
you can use the configuration just to minify, take a look at: https://github.com/frostwire/frostwire/blob/master/android/build.gradle#L142
Why is this issue closed? It is still there.
Using the latest library version: 1.2.7.0
I've added the following rule (also tried a few other variations)
-keep class com.frostwire.jlibtorrent.swig.libtorrent_jni {*;}
You can confirm this error in the following sample app I've created this repo just for this issue.
Just clone and run the project to see the error since minifyenabled
is true
in debug too.
I can't replicate
@abbasshah17 try
classpath 'com.android.tools.build:gradle:3.6.3'
we're very hesitant to build android with gradle 4.0.0, lots of issues when building releases.
I can't replicate
Did you try the sample project I attached?
classpath 'com.android.tools.build:gradle:3.6.3'
Tried changing in the sample, still the same issue... Can you share the ndk version you are using?
You can see them on the .travis.yml of the project.
- env: os_build=android os_arch=arm android_api=19
- env: os_build=android os_arch=arm64 android_api=21
- env: os_build=android os_arch=x86 android_api=19
- env: os_build=android os_arch=x86_64 android_api=21
https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip
You should probably follow the build instructions on Travis and use travis to make your builds.
We also have build scripts if you want to build on your own computer. e.g. https://github.com/frostwire/frostwire-jlibtorrent/blob/master/swig/build-android-x86_64.sh
Finally found a rule that works...
-keep public class com.frostwire.jlibtorrent.swig.** {
*;
}
There is some issue with R8 minifier, the keep rule mentioned in the README or in this thread doesn't work, haven't verified whether it's just the R8 or also proguard or something else. Also haven't verified if this works in proguard.
Strangely the rule only applies when added in app/default module's proguard-rules.pro
.