frostwire / frostwire-jlibtorrent

A swig Java interface for libtorrent by the makers of FrostWire. Develop libtorrent based apps with the joy of coding in Java.
http://www.frostwire.com
MIT License
444 stars 137 forks source link

Release build 1.2.13.0 fails to load on Android due to linkage error #255

Closed vickyoo7 closed 3 years ago

vickyoo7 commented 3 years ago

I tried the release build on arm64 and x86_64 android and on both it failed due to linkage error

java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent

gubatron commented 3 years ago

could you be more specific as to which device and android OS version you're getting these linkage errors and what symbols?

Perhaps a full stack trace report would help.

vickyoo7 commented 3 years ago

Device: OnePlus 5T Android version: Android 10 Cpu Arch: arm64

Note: it crashed on x86_64 Android 10 emulator as well

I also checked Application's lib directory and the so file with correct name is available Stack trace:

--------- beginning of main 03-04 22:59:44.095 9977 9977 W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@f809b3e 03-04 22:59:44.204 9977 9977 I AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's 03-04 22:59:44.231 9977 9977 W anager.adm.lit: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed) 03-04 22:59:44.232 9977 9977 W anager.adm.lit: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed) 03-04 22:59:44.241 9979 9979 I DownloadServic: Late-enabling -Xcheck:jni 03-04 22:59:44.259 9979 9979 E DownloadServic: Unknown bits set in runtime_flags: 0x28000 03-04 22:59:44.275 9977 9977 V FlingOptimizerScroller: FlingOptimizerOverScroller Init 03-04 22:59:44.312 9977 9977 W TabLayout: MODE_SCROLLABLE + GRAVITY_FILL is not supported, GRAVITY_START will be used instead 03-04 22:59:44.551 9977 9977 V ViewRootImpl: The specified message queue synchronization barrier token has not been posted or has already been removed 03-04 22:59:44.589 9977 10816 D DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@dbd2c56[MainActivity] 03-04 22:59:44.591 9977 10816 D ViewRootImpl[MainActivity]: windowFocusChanged hasFocus=true inTouchMode=true 03-04 22:59:44.594 9977 10951 I AdrenoGLES: QUALCOMM build : 6209c5d, Ifdcc64d6e8 03-04 22:59:44.594 9977 10951 I AdrenoGLES: Build Date : 12/12/19 03-04 22:59:44.594 9977 10951 I AdrenoGLES: OpenGL ES Shader Compiler Version: EV031.27.05.03 03-04 22:59:44.594 9977 10951 I AdrenoGLES: Local Branch : mybranchea1c9b4a-9e05-f149-a3b2-1458d0b52ae8 03-04 22:59:44.594 9977 10951 I AdrenoGLES: Remote Branch : quic/gfx-adreno.lnx.1.0.r85-rel 03-04 22:59:44.594 9977 10951 I AdrenoGLES: Remote Branch : NONE 03-04 22:59:44.594 9977 10951 I AdrenoGLES: Reconstruct Branch : NOTHING 03-04 22:59:44.594 9977 10951 I AdrenoGLES: Build Config : C O 9.0.3 AArch64 03-04 22:59:44.603 9977 10951 I AdrenoGLES: PFP: 0x005ff112, ME: 0x005ff066 03-04 22:59:44.734 9977 10951 W Gralloc3: mapper 3.x is not supported 03-04 22:59:45.142 9977 9977 D OnePlusJankManager: Chor uploadMDM JANK_TYPE_ONCE mViewTitle = idm.internet.download.manager.adm.lite/idm.internet.download.manager.MainActivity--- jank level = 2 03-04 22:59:45.187 9977 9977 W anager.adm.lit: Accessing hidden field Landroid/os/Build;->IS_EMULATOR:Z (greylist, reflection, allowed) 03-04 22:59:45.198 9977 11021 I DpmTcmClient: RegisterTcmMonitor from: $Proxy0 03-04 22:59:45.239 9977 11021 I WebViewFactory: Loading com.google.android.webview version 89.0.4389.72 (code 438907234) 03-04 22:59:45.248 9977 9977 D OnePlusJankManager: Chor uploadMDM JANK_TYPE_ONCE mViewTitle = idm.internet.download.manager.adm.lite/idm.internet.download.manager.MainActivity--- jank level = 1 03-04 22:59:45.251 9977 9977 W InputMethodManager: Ignoring onBind: cur seq=25318, given seq=25317 03-04 22:59:45.283 9977 11021 W anager.adm.lit: Accessing hidden method Landroid/os/Trace;->isTagEnabled(J)Z (greylist, reflection, allowed) 03-04 22:59:45.283 9977 11021 W anager.adm.lit: Accessing hidden method Landroid/os/Trace;->traceBegin(JLjava/lang/String;)V (greylist, reflection, allowed) 03-04 22:59:45.283 9977 11021 W anager.adm.lit: Accessing hidden method Landroid/os/Trace;->traceEnd(J)V (greylist, reflection, allowed) 03-04 22:59:45.283 9977 11021 W anager.adm.lit: Accessing hidden method Landroid/os/Trace;->asyncTraceBegin(JLjava/lang/String;I)V (greylist, reflection, allowed) 03-04 22:59:45.283 9977 11021 W anager.adm.lit: Accessing hidden method Landroid/os/Trace;->asyncTraceEnd(JLjava/lang/String;I)V (greylist, reflection, allowed) 03-04 22:59:45.296 9977 9977 I cr_LibraryLoader: Loaded native library version number "89.0.4389.72" 03-04 22:59:45.297 9977 9977 I cr_CachingUmaRecorder: Flushed 4 samples from 4 histograms. 03-04 22:59:45.476 9979 9979 I Perf : Connecting to perf service. 03-04 22:59:45.481 9979 9979 I DownloadServic: [GL_OOM] ClearGrowthLimit 536870912 03-04 22:59:45.486 9979 9979 I MultiDex: VM with version 2.1.0 has multidex support 03-04 22:59:45.486 9979 9979 I MultiDex: Installing application 03-04 22:59:45.486 9979 9979 I MultiDex: VM has multidex support, MultiDex support library is disabled. 03-04 22:59:45.487 9979 9979 V Font : Change font:1 03-04 22:59:45.487 9979 9979 V Font : Default family:android.graphics.Typeface@d905a7bb 03-04 22:59:45.675 9979 9979 W System.err: java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent 03-04 22:59:45.676 9979 9979 W System.err: at com.frostwire.jlibtorrent.swig.libtorrent_jni.(libtorrent_jni.java:33) 03-04 22:59:45.676 9979 9979 W System.err: at com.frostwire.jlibtorrent.swig.libtorrent_jni.new_posix_wrapper(Native Method) 03-04 22:59:45.676 9979 9979 W System.err: at com.frostwire.jlibtorrent.swig.posix_wrapper.(posix_wrapper.java:75) 03-04 22:59:45.676 9979 9979 W System.err: at com.aspsine.multithreaddownload.util.PosixCalls.(PosixCalls.java:17) 03-04 22:59:45.676 9979 9979 W System.err: at com.aspsine.multithreaddownload.util.Utility.buildFileSystem(Utility.java:1430) 03-04 22:59:45.676 9979 9979 W System.err: at acr.browser.lightning.app.BrowserApp.initApp(BrowserApp.java:114) 03-04 22:59:45.676 9979 9979 W System.err: at acr.browser.lightning.app.BrowserApp.onCreate(BrowserApp.java:39) 03-04 22:59:45.676 9979 9979 W System.err: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1204) 03-04 22:59:45.676 9979 9979 W System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6648) 03-04 22:59:45.676 9979 9979 W System.err: at android.app.ActivityThread.access$1600(ActivityThread.java:232) 03-04 22:59:45.676 9979 9979 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1953) 03-04 22:59:45.676 9979 9979 W System.err: at android.os.Handler.dispatchMessage(Handler.java:107) 03-04 22:59:45.676 9979 9979 W System.err: at android.os.Looper.loop(Looper.java:214) 03-04 22:59:45.676 9979 9979 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7697) 03-04 22:59:45.676 9979 9979 W System.err: at java.lang.reflect.Method.invoke(Native Method) 03-04 22:59:45.676 9979 9979 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516) 03-04 22:59:45.676 9979 9979 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 03-04 22:59:45.676 9979 9979 W System.err: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/idm.internet.download.manager.adm.lite-f3Bvwf8PoksqE08GTXB_uw==/base.apk"],nativeLibraryDirectories=[/data/app/idm.internet.download.manager.adm.lite-f3Bvwf8PoksqE08GTXB_uw==/lib/arm64, /data/app/idm.internet.download.manager.adm.lite-f3Bvwf8PoksqE08GTXB_uw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]] couldn't find "libjlibtorrent.so" 03-04 22:59:45.676 9979 9979 W System.err: at java.lang.Runtime.loadLibrary0(Runtime.java:1067) 03-04 22:59:45.676 9979 9979 W System.err: at java.lang.Runtime.loadLibrary0(Runtime.java:1007) 03-04 22:59:45.676 9979 9979 W System.err: at java.lang.System.loadLibrary(System.java:1667) 03-04 22:59:45.676 9979 9979 W System.err: at com.frostwire.jlibtorrent.swig.libtorrent_jni.(libtorrent_jni.java:27) 03-04 22:59:45.676 9979 9979 W System.err: ... 16 more 03-04 22:59:45.677 9979 9979 I DownloadServic: Rejecting re-init on previously-failed class java.lang.Class: java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent 03-04 22:59:45.677 9979 9979 I DownloadServic: (Throwable with no stack trace) 03-04 22:59:45.677 9979 9979 I DownloadServic: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/idm.internet.download.manager.adm.lite-f3Bvwf8PoksqE08GTXB_uw==/base.apk"],nativeLibraryDirectories=[/data/app/idm.internet.download.manager.adm.lite-f3Bvwf8PoksqE08GTXB_uw==/lib/arm64, /data/app/idm.internet.download.manager.adm.lite-f3Bvwf8PoksqE08GTXB_uw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]] couldn't find "libjlibtorrent.so" 03-04 22:59:45.677 9979 9979 I DownloadServic: (Throwable with no stack trace) 03-04 22:59:45.677 9979 9979 I DownloadServic: 03-04 22:59:45.738 9979 11095 I mobile-ffmpeg: Loading mobile-ffmpeg. 03-04 22:59:45.752 9979 11095 I mobile-ffmpeg: Loaded mobile-ffmpeg-min-arm64-v8a-4.4-lts-20200802. 03-04 22:59:45.753 9979 11098 D mobile-ffmpeg: Callback thread started. 03-04 22:59:45.753 9979 11098 D mobile-ffmpeg: Callback thread stopped. 03-04 22:59:45.771 9977 9977 D PollServiceConnection: onServiceConnected

gubatron commented 3 years ago

Thank you for this, I'll be going over this ticket today

gubatron commented 3 years ago

Crash replicated, investigating what happened with the build.

03-04 18:49:36.512 21935 21935 D AndroidRuntime: Shutting down VM
03-04 18:49:36.513 21935 21935 E AndroidRuntime: FATAL EXCEPTION: com.frostwire.android.gui.MainApplication.onCreateSafe(MainApplication.java:102)
03-04 18:49:36.513 21935 21935 E AndroidRuntime: Process: com.frostwire.android, PID: 21935
03-04 18:49:36.513 21935 21935 E AndroidRuntime: java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:33)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.jlibtorrent.swig.libtorrent_jni.new_posix_wrapper(Native Method)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.jlibtorrent.swig.posix_wrapper.<init>(posix_wrapper.java:75)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.android.AndroidPlatform$PosixCalls.<init>(AndroidPlatform.java:120)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.android.AndroidPlatform.buildFileSystem(AndroidPlatform.java:99)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.android.AndroidPlatform.<init>(AndroidPlatform.java:52)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.android.gui.MainApplication.onCreate(MainApplication.java:68)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1197)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6661)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at android.app.ActivityThread.access$1700(ActivityThread.java:232)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1966)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:107)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:214)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7710)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
03-04 18:49:36.513 21935 21935 E AndroidRuntime: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.frostwire.android-P7D4A9eTfc2VGyV46DDVNQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.frostwire.android-P7D4A9eTfc2VGyV46DDVNQ==/lib/arm64, /data/app/com.frostwire.android-P7D4A9eTfc2VGyV46DDVNQ==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]] couldn't find "libjlibtorrent.so"
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at java.lang.System.loadLibrary(System.java:1667)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:27)
03-04 18:49:36.513 21935 21935 E AndroidRuntime:    ... 16 more
gubatron commented 3 years ago

gradle task in build.gradle says:

from fileTree(dir: 'swig/bin/release/android', include: 'arm64-v8a/libjlibtorrent.so')
into 'lib/'
rename(".so", "-${version}.so")

Inside jlibtorrent-android-arm64-1.2.13.0.jar we have: lib/arm64-v8a/libjlibtorrent-1.2.13.0.so

Error says it's looking for libjlibtorrent.so, not libjlibjtorrent-1.2.13.0.so, at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:27)

Before it tries that, it's trying also the library name with the version number.

try {
                    System.loadLibrary("jlibtorrent-" + jlibtorrentVersion());
                } catch (LinkageError e) {
                    // give it a try to the name without version                                                  
                    System.loadLibrary("jlibtorrent");
                }

Will try to output the version number it's trying, let's see what jlibtorrentVersion() is returning...

public static String jlibtorrentVersion() {
        // extracted from the gradle with the run-swig step                                                       
        return "1.2.13.0";
    }

Looks good.

Will see if I can get more information about the LinkageError

vickyoo7 commented 3 years ago

Great, let me know if you require any more information

gubatron commented 3 years ago

update: Still working on this, more focused during the weekend I hope.

Currently I'm working on a Docker image + container to easily build these binaries in a deterministic fashion.

The last 2 armv8 builds I've done on 2 different linux machines are crashing on my cellphone, for some reason when the app launches it's not finding the .so file, something I'm not seeing is damaging the .so, perhaps a missing symbol or something.

I hope to be able to see this with the Docker build.

gubatron commented 3 years ago

New Binaries for Android uploaded. Windows, Mac and Linux coming this weekend.

I can no longer replicate the Linkage issue! wohoo

https://github.com/frostwire/frostwire-jlibtorrent/releases/tag/release%2F1.2.13.0

gubatron commented 3 years ago

Dear @vickyoo7 once you test, if you no longer have the linkage error feel free to Close the ticket.

vickyoo7 commented 3 years ago

Dear @vickyoo7 once you test, if you no longer have the linkage error feel free to Close the ticket.

Tested all 4 Android variants and all work well. Thank you for fixing the issue. Closing the issue