GithubHelp home page GithubHelp logo

soloader's Introduction

SoLoader

Build CI License Maven Central

SoLoader is a native code loader for Android. It takes care of unpacking your native libraries and recursively loads dependencies on Android API 23 and earlier, since those old OS versions do not support all of that functionality out of box.

Requirements

SoLoader is useful for applications running on Android API 23 and earlier. SoLoader should not be used on Android API 24 and above unless the app is delivered as Exopackage, requires Android Native Library Merging or uses Superpack compression.

Including SoLoader in your apps

You can use prebuilt aars or fetch SoLoader from Maven repository by adding the following to your build.gradle file:

implementation 'com.facebook.soloader:soloader:0.11.0+'

Building from source

To build SoLoader from source you'll need Buck. Once you have Buck installed execute following commands from the project root directory:

  buck fetch //...
  buck build :soloader

The build command generates buck-out/gen/soloader.aar file.

Join our community

Please use our issues page to let us know of any problems. See the CONTRIBUTING file for how to help out.

License

SoLoader is Apache-2.0-licensed.

soloader's People

Contributors

adicatana avatar bolinfest avatar davyllll avatar dcolascione avatar dreiss avatar jeremydubreil avatar jkeljo avatar joelmccall avatar joshuagross avatar junqiwang avatar michalgr avatar mzlee avatar ndmitchell avatar nslingerland avatar oprisnik avatar passy avatar sashkostashuk avatar scottrice avatar simpleton avatar smeenai avatar strulovich avatar thisisjimmyfb avatar tido64 avatar tnovak avatar ttsugriy avatar usikder avatar vener91 avatar yanivsb avatar zertosh avatar zpao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soloader's Issues

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libimagepipeline.so


screen shot 2019-02-27 at 7 07 38 pm

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libimagepipeline.so caused by: dlopen failed: "/mnt/expand/7c0f06c2-1644-460f-8533-efe2fb639ade/user/0/com.studio/lib-main/libimagepipeline.so" is 32-bit instead of 64-bit
       at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SourceFile:703)
       at com.facebook.soloader.SoLoader.loadLibraryBySoName(SourceFile:564)
       at com.facebook.soloader.SoLoader.loadLibrary(SourceFile:500)
       at com.facebook.soloader.SoLoader.loadLibrary(SourceFile:455)
       at com.facebook.imagepipeline.nativecode.ImagePipelineNativeLoader.load(SourceFile:40)
       at com.facebook.imagepipeline.memory.NativeMemoryChunk.(SourceFile:31)
       at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc(SourceFile:25)
       at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc(SourceFile:13)
       at com.facebook.imagepipeline.memory.BasePool.get(SourceFile:267)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream.(SourceFile:51)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(SourceFile:73)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(SourceFile:24)
       at com.facebook.imagepipeline.cache.BufferedDiskCache.readFromDiskCache(SourceFile:373)
       at com.facebook.imagepipeline.cache.BufferedDiskCache.access$400(SourceFile:35)
       at com.facebook.imagepipeline.cache.BufferedDiskCache$2.call(SourceFile:193)
       at com.facebook.imagepipeline.cache.BufferedDiskCache$2.call(SourceFile:174)
       at bolts.Task$4.run(SourceFile:357)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(SourceFile:51)
       at java.lang.Thread.run(Thread.java:818)
ndk {
abiFilters 'armeabi-v7a'
}

SoLoader version. [0.5.1]

I think this is relevant/cause of facebook/fresco#2296 pls check

load error

when app is in system/app and system/lib and apk all has so, soloader will copy so file to data/app//lib-main
will have load error

Library load fails if thread receives interrupt

Exception: java.nio.channels.ClosedByInterruptException
at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:113)
at java.nio.FileChannelImpl.readImpl(FileChannelImpl.java:311)
at java.nio.FileChannelImpl.read(FileChannelImpl.java:274)
at com.facebook.soloader.MinElf.read(SourceFile:254)
at com.facebook.soloader.MinElf.getu32(SourceFile:276)
at com.facebook.soloader.MinElf.extract_DT_NEEDED(SourceFile:73)
at com.facebook.soloader.MinElf.extract_DT_NEEDED(SourceFile:48)
at com.facebook.soloader.DirectorySoSource.getDependencies(SourceFile:113)
at com.facebook.soloader.DirectorySoSource.loadDependencies(SourceFile:95)
at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(SourceFile:73)
at com.facebook.soloader.DirectorySoSource.loadLibrary(SourceFile:52)
at com.facebook.soloader.ApplicationSoSource.loadLibrary(SourceFile:81)
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SourceFile:636)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SourceFile:547)
at com.facebook.soloader.SoLoader.loadLibrary(SourceFile:2484)
at com.facebook.imagepipeline.nativecode.ImagePipelineNativeLoader.load(SourceFile:40)
at com.facebook.imagepipeline.memory.NativeMemoryChunk.(SourceFile:31)
at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.free(SourceFile:18)
at com.facebook.imagepipeline.memory.BasePool.get(SourceFile:255)
at com.facebook.imagepipeline.memory.NativePooledByteBufferOutputStream.(SourceFile:49)
at com.facebook.imagepipeline.memory.NativePooledByteBufferFactory.newOutputStream(SourceFile:1139)
at com.facebook.imagepipeline.producers.NetworkFetchProducer.onResponse(SourceFile:88)
at com.facebook.imagepipeline.producers.NetworkFetchProducer$1.onResponse(SourceFile:68)
at com.example.download
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)

We faced a lot of crashes in Fresco:
Exception: java.lang.NoClassDefFoundError: com/facebook/imagepipeline/memory/NativeMemoryChunk
So we added our own logs in SoLoader. It turns out it won't properly handle Thread#interrupt() while loading libraries. We patched our custom NetworkFetcher to avoid sending such interrupts but maybe it's not desired behavior for SoLoader either.

Could not find methods

Running into an issue where a bunch of methods could not be found.

I/dalvikvm( 5146): Could not find method com.facebook.soloader.SysUtil.getSupportedAbis, referenced from method com.facebook.soloader.SoLoader.areSoSourcesAbisSupported
W/dalvikvm( 5146): VFY: unable to resolve static method 1236: Lcom/facebook/soloader/SysUtil;.getSupportedAbis ()[Ljava/lang/String;
D/dalvikvm( 5146): VFY: replacing opcode 0x71 at 0x0019
W/dalvikvm( 5146): VFY: unable to find class referenced in signature ([Lcom/facebook/soloader/SoSource;)
I/dalvikvm( 5146): Could not find method com.facebook.soloader.Api18TraceUtils.beginTraceSection, referenced from method com.facebook.soloader.SoLoader.doLoadLibraryBySoName
W/dalvikvm( 5146): VFY: unable to resolve static method 1185: Lcom/facebook/soloader/Api18TraceUtils;.beginTraceSection (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
D/dalvikvm( 5146): VFY: replacing opcode 0x71 at 0x0037
W/dalvikvm( 5146): VFY: array-length on non-array
W/dalvikvm( 5146): VFY:  rejecting opcode 0x21 at 0x004e
W/dalvikvm( 5146): VFY:  rejected Lcom/facebook/soloader/SoLoader;.doLoadLibraryBySoName (Ljava/lang/String;ILandroid/os/StrictMode$ThreadPolicy;)V
W/dalvikvm( 5146): Verifier rejected class Lcom/facebook/soloader/SoLoader;
D/AndroidRuntime( 5146): Shutting down VM

I even added implementation 'com.facebook.soloader:soloader:0.8.0' to my dependencies. I played around with all the release versions, but still no dice

Use labels to mark issues in the repo

🙌 Hi!

I found SoLoader very interesting and wanted to contribute to it. But i found out that the issues in the repo are not marked with labels. So, it is quite to difficult to filter out the issues I could work on.

Would it be possible if you could mark the issues with relevant labels? Also, if there are any good first issues please let me know, I'd love to put my part in this open source loader.

dlopen failed: "/lib-main/libc++_shared.so" is for EM_ARM (40) instead of EM_386 (3)

We're having .so loading error when running app on Android emulator R level. Doesn't seems to appear on API 29.

I've verified that the apk has correct architecture in the proper folder:

unzip ./android/app/build/outputs/apk/debug/app-debug.apk -d /tmp/apk-debug
gobjdump -f /tmp/apk-debug/lib/x86/*.so | grep arch
architecture: i386, flags 0x00000150:

After apk install the lib folder contains proper i386 .so-s.
But when starting the app the lib-main folder contains ARM .so-s.

See the relevant logcat in this gist
https://gist.github.com/mfazekas/c593726e061a59d265835ead1c5db0dd

Not sure if related but the log has those line:

2020-04-02 11:21:18.064 10842-10842/com.rnmapboxglexample D/ApkSoSource: allowing consideration of /data/app/~~fFkI_5OwU8XV6z9_a0xypA==/com.rnmapboxglexample-Lwh6zsqdqwYFSjqSz5i5rA==/lib/x86/libc++_shared.so: sysdir file length is 997224, but the file is 575328 bytes long in the APK

I can confirm that he file with length 997224 is 386. The arm version which is incorrectly used has 575328 bytes.

https://github.com/react-native-mapbox-gl/maps/issues/737

No static method loadLibrary

java.lang.NoSuchMethodError: No static method loadLibrary(Ljava/lang/String;)V in class Lcom/facebook/soloader/SoLoader; or its super classes (declaration of 'com.facebook.soloader.SoLoader' appears in base.apk)
at com.facebook.yoga.YogaNode.(YogaNode.java:24)

Can't load libraries that are in dynamic feature modules

I'm trying to include a React Native activity in a dynamic feature module. It works when it's included in the base APK, but it looks like some hackery is needed when loading native libraries that are in an installed dynamic feature module: SplitInstallHelper.loadLibrary() should be used on 26+ rather than System.loadLibrary(). Currently I'm getting a crash saying the native library couldn't be found, and this seems like the most likely culprit.
Since SoLoader is the one making the actual call, I'm not sure how I could do that from my end. I tried using sSystemLoadLibraryWrapper, but it looks like my loadLibrary() never gets called.

Memory leak in SoLoader

Hi,
I landed here during the research of a memory leak issue on an android app. It's a fork with implementation of the jitsi-meet SDK. In certain conditions (reproduceable) the app closes and some seconds later I get a leak notification from LeakCanary:

HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS

References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.

72099 bytes retained by leaking objects
Signature: 6173255683997cea5a863ec78ff85dede6c116
┬───
│ GC Root: Global variable in native code
│
├─ dalvik.system.PathClassLoader instance
│    Leaking: NO (SoLoader↓ is not leaking and A ClassLoader is never leaking)
│    ↓ PathClassLoader.runtimeInternalObjects
├─ java.lang.Object[] array
│    Leaking: NO (SoLoader↓ is not leaking)
│    ↓ Object[].[590]
├─ com.facebook.soloader.SoLoader class
│    Leaking: NO (a class is never leaking)
│    ↓ static SoLoader.sBackupSoSources
│                      ~~~~~~~~~~~~~~~~
├─ com.facebook.soloader.UnpackingSoSource[] array
│    Leaking: UNKNOWN
│    ↓ UnpackingSoSource[].[0]
│                          ~~~
├─ com.facebook.soloader.ApkSoSource instance
│    Leaking: UNKNOWN
│    ↓ ApkSoSource.mContext
│                  ~~~~~~~~
╰→ <appname>.MainActivity instance
​     Leaking: YES (ObjectWatcher was watching this because <appname>.MainActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
​     key = cae55a22-9a30-4fa8-94c6-b1fbc229ca6d
​     watchDurationMillis = 5209
​     retainedDurationMillis = 200
====================================
0 LIBRARY LEAKS

A Library Leak is a leak caused by a known bug in 3rd party code that you do not have control over.
See https://square.github.io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks
====================================
METADATA

Please include this in bug reports and Stack Overflow questions.

Build.VERSION.SDK_INT: 29
Build.MANUFACTURER: OnePlus
LeakCanary version: 2.3
App process name: <appname>
Analysis duration: 8635 ms
Heap dump file path: /data/user/0/<appname>/files/leakcanary/2020-05-28_23-06-42_002.hprof
Heap dump timestamp: 1590700014275
====================================

I don't know SoLoader but after some digging in the source code, I have an assumption:

  • ApkSoSource keeps a reference to the application context
  • this specific ApkSoSource is kept in an array in SoLoader (.sBackupSoSources)
  • this array is static

So we have a static reference to an application context which causes the mentioned memory leak.

Application not responding when we switch to Android App bundle

We are using v0.6.0 and seeing a lot of ANRs from Google Play console:

"main" prio=5 tid=1 Native
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x754ebb28 self=0x74d2e14c00
  | sysTid=29962 nice=0 cgrp=default sched=0/0 handle=0x7558887548
  | state=D schedstat=( 979726628 482621237 1056 ) utm=44 stm=53 core=1 HZ=100
  | stack=0x7fc2503000-0x7fc2505000 stackSize=8MB
  | held mutexes=
  #00  pc 000000000006e5fc  /system/lib64/libc.so (fsync+8)
  #01  pc 0000000000003670  /system/lib64/libopenjdkjvm.so (JVM_Sync+20)
  #02  pc 000000000001c494  /system/lib64/libopenjdk.so (FileDescriptor_sync+40)
  at java.io.FileDescriptor.sync (FileDescriptor.java)
  at com.facebook.soloader.SysUtil.fsyncRecursive (SysUtil.java:192)
  at com.facebook.soloader.SysUtil.fsyncRecursive (SysUtil.java:185)
  at com.facebook.soloader.UnpackingSoSource$1.run (UnpackingSoSource.java:362)
  at com.facebook.soloader.UnpackingSoSource.refreshLocked (UnpackingSoSource.java:377)
  at com.facebook.soloader.UnpackingSoSource.prepare (UnpackingSoSource.java:420)
  at com.facebook.soloader.SoLoader.initSoSources (SoLoader.java:304)
  at com.facebook.soloader.SoLoader.init (SoLoader.java:181)
  at com.facebook.soloader.SoLoader.init (SoLoader.java:164)
  at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:68)
  at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:45)

Interestingly, we found that every time we released a new version, ANRs went up and then went down:
image

This issue only occurs when we switch to Android App Bundle, is this a compatibility issue?

readlink failed: EACCES (Permission denied)

I get the following error:
Caused by: android.system.ErrnoException: readlink failed: EACCES (Permission denied)
1 | libcore.io.Posix.readlink | Posix.java
2 | libcore.io.BlockGuardOs.readlink | BlockGuardOs.java, line 235
3 | android.system.Os.readlink | Os.java, line 372
4 | com.facebook.soloader.SysUtil$LollipopSysdeps.getSupportedAbis

I'm using a version that includes #45 Optimize extraction strategy. From the stacktrace it looks like this is the line it's crashing at:
b2555b8#diff-fbed63fbbcc576af65201760b6baf3daR131

Is there another way to find out if we're using 64-bit?

I get thousands of these errors from users with various devices (HUAWEI ALE-L21, SAMSUNG, SM-J500M, HUAWEI CAM-L03, SAMSUNG SM-J700M, HUAWEI ALE-L23) and Android versions (99.9% of crashes comes from this range: Android 5.0 - Android 6.0.1)

java.lang.VerifyError: com/facebook/i/k at SoLoader.initImpl$230dc011(SoLoader.java:203)

Description

I posted the exact same issue to Fresco (facebook/fresco#2039), but I believe that it's actually for you.

Crash is happening on Android 4.x devices, when APK is built with ProGuard enabled and 'proguard-android-optimize.txt' configuration file.

Reproduction

  1. Get an Android 4.x device
  2. Build an app with following build settings ("-optimize" is the important part):
debug {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'proguard-fresco.pro'
}
  1. BOOM!

You can find all the detailed information and system dumps here: http://crashes.to/s/c450feed2e9

Additional Information

  • Fresco version: 1.8.0
  • Platform version: Android 4.x.

zip_slip

Hello:
I am a member of the 360 ​​code security team. I found a possible zipslip vulnerability in SoLoader in our open source code detection project. The details are as follows:
In the effortDsos() in ExtractFromZipSoSource.java, the zip is decompressed, but the zip problem is not verified. When the decompressed entry name has "../", it will overwrite other files in the system.
图片

FileNotFoundException on ZTE Grand X Max 2

Fresco is using SoLoader and we got a bug report (facebook/fresco#2176) that on the ZTE Grand X Max 2 (API 23), SoLoader cannot be initialized:

Caused by java.io.FileNotFoundException: /data/user/0/com.remind101/lib-main/dso_lock: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileOutputStream.(FileOutputStream.java:87)
at java.io.FileOutputStream.(FileOutputStream.java:72)
at com.facebook.soloader.FileLocker.(FileLocker.java:28)
at com.facebook.soloader.FileLocker.lock(FileLocker.java:24)
at com.facebook.soloader.UnpackingSoSource.prepare(UnpackingSoSource.java:393)
at com.facebook.soloader.SoLoader.initImpl(SoLoader.java:211)
at com.facebook.soloader.SoLoader.init(SoLoader.java:120)
at com.facebook.soloader.SoLoader.init(SoLoader.java:104)
at com.facebook.drawee.backends.pipeline.Fresco.initialize(Fresco.java:63)
at com.facebook.drawee.backends.pipeline.Fresco.initialize(Fresco.java:46)
Caused by android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Posix.java)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
at java.io.FileOutputStream.(FileOutputStream.java:87)
at java.io.FileOutputStream.(FileOutputStream.java:72)
at com.facebook.soloader.FileLocker.(FileLocker.java:28)
at com.facebook.soloader.FileLocker.lock(FileLocker.java:24)
at com.facebook.soloader.UnpackingSoSource.prepare(UnpackingSoSource.java:393)
at com.facebook.soloader.SoLoader.initImpl(SoLoader.java:211)
at com.facebook.soloader.SoLoader.init(SoLoader.java:120)
at com.facebook.soloader.SoLoader.init(SoLoader.java:104)
at com.facebook.drawee.backends.pipeline.Fresco.initialize(Fresco.java:63)
at com.facebook.drawee.backends.pipeline.Fresco.initialize(Fresco.java:46)

It looks like ZTE has modified Android for whatever reason that prevents us from loading native libraries through SoLoader. The line where this is failing is here: https://github.com/facebook/SoLoader/blob/master/java/com/facebook/soloader/FileLocker.java#L35

try-with-resources not supported below API 19

I noticed that a few of the classes use try-with-resources blocks, which are not supported below API 19. However, the minimum SDK in the manifest is listed as 9.

It seems that try-with-resources "mostly work" down to API 15.
See: https://code.google.com/p/android/issues/detail?id=73483)

I haven't heard of anyone successfully using try-with-resources below API 14, and the support below 19 doesn't appear to be guaranteed. Is there a reason for using try-with-resources in this codebase other than convenience?

Reflection blacklist Ljava/lang/Runtime;->nativeLoad use(s)

If you use google appcompat script to scan the project, this error will be reported:
Reflection blacklist Ljava/lang/Runtime;->nativeLoad use(s):
Lcom/facebook/soloader/SoLoader;->getNativeLoadRuntimeMethod()Ljava/lang/reflect/Method;

so it will block the app on Android Q: https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces

btw I am using soloader 0.5.1, however the issue still exists in the latest version.

SoLoader 0.8.0 couldn't find DSO to load - issue on .apk build

MyApp is crashing while performing tests on Firebase Test lab emulators (x86).
Downgrading to 0.6.1 is fixing the problem.

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libyoga.so caused by: APK was built for a different platform
	at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:789)
	at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:639)
	at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:577)
	at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:525)
	at com.facebook.yoga.YogaNative.<clinit>(YogaNative.java:15)
	at com.facebook.yoga.YogaConfig.<init>(YogaConfig.java:20)
	at com.facebook.yoga.YogaConfigFactory.create(YogaConfigFactory.java:5)
	at com.facebook.litho.yoga.LithoYogaFactory.createYogaConfig(LithoYogaFactory.java:26)
	at com.facebook.litho.NodeConfig.<clinit>(NodeConfig.java:45)

UnsatisfiedLinkError: couldn't find DSO to load: libc++_shared.so caused by: dlopen failed

Unable to load the so file from the internal storage directory.

		    --------- beginning of crash
2019-05-15 20:55:36.828 12231-12231/com.sample.preprod E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.sample.preprod, PID: 12231
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libc++_shared.so caused by: dlopen failed: library "/storage/emulated/0/sample/libs/armeabi-v7a/libc++_shared.so" needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.android.sample.ui.sun.activities.GameRNActivity.loadNativeLibrary(GameRNActivity.java:273)
        at com.android.sample.ui.sun.activities.GameRNActivity.onCreate(GameRNActivity.java:178)
        at android.app.Activity.performCreate(Activity.java:6868)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2676)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2784)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6238)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
2019-05-15 20:55:37.155 12231-12231/com.sample.preprod I/Process: Sending signal. PID: 12231 SIG: 9

App Bundle : couldn't find DSO to load: libfb.so

We tried to use App Bundle on our native Android app, but it crashes right after we launch the installed apks with the following error:

2019-08-27 16:48:27.394 E/com.facebook.soloader.NativeLibrary: Failed to load native lib: 
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libfb.so
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:455)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:371)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:336)
        at com.facebook.soloader.NativeLibrary.loadLibraries(NativeLibrary.java:56)
        at com.facebook.soloader.NativeLibrary.ensureLoaded(NativeLibrary.java:77)
        at com.facebook.android.crypto.keychain.AndroidCryptoLibrary.ensureCryptoLoaded(AndroidCryptoLibrary.java:32)
        at com.facebook.crypto.Crypto.isAvailable(Crypto.java:57)

With apk, it works fine.

Even the "patched" here, on the merged PR, doesn't work for us #26

We've made some research and it looks like it is related to this issue, but we couldn't figure out how to fix it. facebook/react-native#23764
Should we have to wait until this issue is fixed? or does anyone know how to fix it?

Edit: We are using
implementation ("com.facebook.conceal:conceal:2.0.2@aar")

Thank you in advance :)

ArrayStoreException in ExtraFormZipSoSource.java

My online app found this problem and it happened 30 times per day

Stack details:

Caused by:

  • java.lang.ArrayStoreException:com.facebook.soloader.ExtractFromZipSoSource$ZipDso cannot be stored in an array of type com.facebook.soloader.ExtractFromZipSoSource$ZipDso[]
  • java.util.AbstractCollection.toArray(AbstractCollection.java:196)
  • com.facebook.soloader.ExtractFromZipSoSource$ZipUnpacker.ensureDsos
  • com.facebook.soloader.ExtractFromZipSoSource$ZipUnpacker.getDsoManifest
  • ...

AppBundle: Sideloaded 32bit app will be crashed on 64bit devices

I found another issue related sideload with AppBundle(Split Apk format)

  1. Sideload app that have only 32bit ABI split apk format into 64bit device.
$ adb install-multiple base.apk config.armeabi_v7a.apk
$ adb shell dumpsys package your.app.package_name |grep splits
splits=[base, config.armeabi_v7a]
  1. Open Google Play Store and go to app description, app is update-able even if has same version code.
  2. Update app and google play deliver 64bit abi split apk because device is 64bit.
$ adb shell dumpsys package your.app.package_name |grep splits
splits=[base, config.arm64_v8a, config.armeabi_v7a]
  1. SoLoader raise java.lang.UnsatisfiedLinkError
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libyoga.so caused by: couldn't find DSO to load: libfb.so caused by: dlopen failed: "/data/data/your.app.package_name/lib-1/libfb.so" is 32-bit instead of 64-bit
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:774)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:627)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:565)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:513)
at com.facebook.yoga.YogaNative.<clinit>(YogaNative.java:15)

Caused by java.io.IOException: Resource deadlock would occur

We are using Fresco, and initialize it in Application.onCreate().During initialization Fresco initilizes SoLoader, and in some cases SoLoader initialization fails Could not initialise SoLoader
Fresco version: 2.0.0
Crashlytics with the following error:

Caused by java.io.IOException: Resource deadlock would occur
       at sun.nio.ch.FileDispatcherImpl.lock0(FileDispatcherImpl.java)
       at sun.nio.ch.FileDispatcherImpl.lock(FileDispatcherImpl.java:115)
       at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1097)
       at java.nio.channels.FileChannel.lock(FileChannel.java:1053)
       at com.facebook.soloader.FileLocker.<init>(FileLocker.java:38)
       at com.facebook.soloader.FileLocker.lock(FileLocker.java:31)
       at com.facebook.soloader.UnpackingSoSource.prepare(UnpackingSoSource.java:417)
       at com.facebook.soloader.SoLoader.initSoSources(SoLoader.java:304)
       at com.facebook.soloader.SoLoader.init(SoLoader.java:181)
       at com.facebook.soloader.SoLoader.init(SoLoader.java:164)
       at com.facebook.drawee.backends.pipeline.Fresco.initialize(Fresco.java:68)
       at com.facebook.drawee.backends.pipeline.Fresco.initialize(Fresco.java:45)
       at com.netease.vopen.app.VopenApplicationLike.initFresco(VopenApplicationLike.java:535)
       at com.netease.vopen.app.VopenApplicationLike.onCreate(VopenApplicationLike.java)
       at com.tencent.tinker.entry.TinkerApplicationInlineFence.onCreateImpl_$noinline$(TinkerApplicationInlineFence.java:99)
       at com.tencent.tinker.entry.TinkerApplicationInlineFence.onCreate(TinkerApplicationInlineFence.java:110)
       at com.tencent.tinker.loader.app.TinkerApplication.onCreate(TinkerApplication.java:153)
       at com.netease.nis.wrapper.MyApplication.onCreate(MyApplication.java:24)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1162)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6717)
       at android.app.ActivityThread.access$2000(ActivityThread.java:273)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2020)
       at android.os.Handler.dispatchMessage(Handler.java:112)
       at android.os.Looper.loop(Looper.java:216)
       at android.app.ActivityThread.main(ActivityThread.java:7625)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

makeLdLibraryPath and unpackLibraryBySoName purpose

Minor documentation request

I am using SoLoader in a custom way in my app and I am prepending a new subclass of SoSource with SoLoader.prependSoSource.

I noticed SoSource class has methods addToLdLibraryPath called by SoLoader.makeLdLibraryPath, and unpackLibrary called by SoLoader.unpackLibraryAndDependencies, respectively.

I am confused about what's the purpose of these methods, and who's supposed to call them. I know React Native is a consumer of SoLoader project, but it doesn't even use these methods. Are these methods only for internal FB projects?

If I am unable to know the locations of the .so files (I am loading in an experimental way), but still able to load them in loadLibrary method, what's the best way to handle unpackLibrary method? Should I try ClassLoader.findLibrary methods that might work...

Race condition in initializer

if (!NativeLoader.isInitialized()) {
NativeLoader.init(new NativeLoaderToSoLoaderDelegate());
}

If the initializer is called twice at the same time (e.g. SoLoader.init in Application.onCreate and Fresco.initialize on a worker thread) the app would crash with

java.lang.IllegalStateException: Cannot re-initialize NativeLoader.

Where Fresco checks NativeLoader.isInitialized and calls SoLoader.init:

https://github.com/facebook/fresco/blob/3c39beb47cb514d047eaaf9251badcf6f6db45ea/drawee-backends/drawee-pipeline/src/main/java/com/facebook/drawee/backends/pipeline/Fresco.java#L77-L102

https://github.com/facebook/fresco/blob/master/soloader/src/main/java/com/facebook/imagepipeline/nativecode/NativeCodeInitializer.java

Currently, there's nothing like NativeLoader.initIfNotAlready.

SoLoader not compatible with uncompressed native libraries Android feature

I work on the Android App Bundle, and we're getting a raising number of developers reporting crash reports when trying to load native libraries with Facebook's SoLoader.

I've tried to trace what the SoLoader does and I may have gotten it wrong, but it seems that it expects the native libraries to be extracted from the APKs during the installation (at least in some circumstances which I couldn't pin-point precisely).

However, since Android Studio 3.3 (and bundletool 0.6.0), when building an Android App Bundle, native libraries are no longer extracted from the APK during the installation due to a feature called "uncompressed native libraries" of the Android platform introduced in Android M which allows the native libraries to remain uncompressed in the APK so that the platform doesn't have to make a copy on the device before reading them.

WrongAbiError: APK was built for a different platform, fresco 2.1.0

Description

#39
After updating to fresco:2.1.0 we still have crashes:

Fatal Exception: com.facebook.soloader.SoLoader$WrongAbiError: APK was built for a different platform
       at com.facebook.soloader.SoLoader.loadLibraryBySoName + 645(SoLoader.java:645)
       at com.facebook.soloader.SoLoader.loadLibrary + 577(SoLoader.java:577)
       at com.facebook.soloader.SoLoader.loadLibrary + 525(SoLoader.java:525)
       at com.facebook.soloader.NativeLoaderToSoLoaderDelegate.loadLibrary + 24(NativeLoaderToSoLoaderDelegate.java:24)
       at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary + 43(NativeLoader.java:43)
       at com.facebook.imagepipeline.memory.NativeMemoryChunk.<clinit> + 31(NativeMemoryChunk.java:31)
       at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc + 29(NativeMemoryChunkPool.java:29)
       at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc + 15(NativeMemoryChunkPool.java:15)
       at com.facebook.imagepipeline.memory.BasePool.get + 243(BasePool.java:243)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream.<init> + 51(MemoryPooledByteBufferOutputStream.java:51)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer + 73(MemoryPooledByteBufferFactory.java:73)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer + 24(MemoryPooledByteBufferFactory.java:24)
       at com.facebook.imagepipeline.producers.LocalFetchProducer.getByteBufferBackedEncodedImage + 78(LocalFetchProducer.java:78)
       at com.facebook.imagepipeline.producers.LocalFetchProducer.getEncodedImage + 88(LocalFetchProducer.java:88)
       at com.facebook.imagepipeline.producers.LocalResourceFetchProducer.getEncodedImage + 33(LocalResourceFetchProducer.java:33)
       at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult + 44(LocalFetchProducer.java:44)
       at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult + 40(LocalFetchProducer.java:40)
       at com.facebook.common.executors.StatefulRunnable.run + 43(StatefulRunnable.java:43)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1112(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 587(ThreadPoolExecutor.java:587)
       at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run + 50(PriorityThreadFactory.java:50)
       at java.lang.Thread.run + 818(Thread.java:818)
Caused by java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libimagepipeline.so caused by: dlopen failed: "/data/data/ru.app/lib-main/libimagepipeline.so" has unexpected e_machine: 40
       at com.facebook.soloader.SoLoader.doLoadLibraryBySoName + 789(SoLoader.java:789)
       at com.facebook.soloader.SoLoader.loadLibraryBySoName + 639(SoLoader.java:639)
       at com.facebook.soloader.SoLoader.loadLibrary + 577(SoLoader.java:577)
       at com.facebook.soloader.SoLoader.loadLibrary + 525(SoLoader.java:525)
       at com.facebook.soloader.NativeLoaderToSoLoaderDelegate.loadLibrary + 24(NativeLoaderToSoLoaderDelegate.java:24)
       at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary + 43(NativeLoader.java:43)
       at com.facebook.imagepipeline.memory.NativeMemoryChunk.<clinit> + 31(NativeMemoryChunk.java:31)
       at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc + 29(NativeMemoryChunkPool.java:29)
       at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc + 15(NativeMemoryChunkPool.java:15)
       at com.facebook.imagepipeline.memory.BasePool.get + 243(BasePool.java:243)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream.<init> + 51(MemoryPooledByteBufferOutputStream.java:51)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer + 73(MemoryPooledByteBufferFactory.java:73)
       at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer + 24(MemoryPooledByteBufferFactory.java:24)
       at com.facebook.imagepipeline.producers.LocalFetchProducer.getByteBufferBackedEncodedImage + 78(LocalFetchProducer.java:78)
       at com.facebook.imagepipeline.producers.LocalFetchProducer.getEncodedImage + 88(LocalFetchProducer.java:88)
       at com.facebook.imagepipeline.producers.LocalResourceFetchProducer.getEncodedImage + 33(LocalResourceFetchProducer.java:33)
       at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult + 44(LocalFetchProducer.java:44)
       at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult + 40(LocalFetchProducer.java:40)
       at com.facebook.common.executors.StatefulRunnable.run + 43(StatefulRunnable.java:43)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1112(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 587(ThreadPoolExecutor.java:587)
       at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run + 50(PriorityThreadFactory.java:50)
       at java.lang.Thread.run + 818(Thread.java:818)

Application.java

OkHttpClient.Builder ohcb = new OkHttpClient.Builder()
                .proxy(Proxy.NO_PROXY)
                .connectTimeout(20, TimeUnit.SECONDS)
                .readTimeout(20, TimeUnit.SECONDS)
                .writeTimeout(20, TimeUnit.SECONDS)
                .addInterceptor(new Interceptor() {
                    @Override
                    public Response intercept(Chain chain) throws IOException {
                        Request.Builder ongoing = chain.request().newBuilder();
                        ongoing.addHeader("X-device", "android");
                        // etc..
                        return chain.proceed(ongoing.build());
                    }
                });

        ImagePipelineConfig imagePipelineConfig = OkHttpImagePipelineConfigFactory
                .newBuilder(this, ohcb.build())
                .build();
        Fresco.initialize(this, imagePipelineConfig);

Reproduction

I can't reproduce this crash on all my devices and emulators.

Additional Information

  • Fresco version: 2.1.0
  • imagepipeline-okhttp3: 2.1.0
  • androidx
  • we use apk, NOT bundle

For now, we have only several crashes, all of this on ASUS ZenFone 2 (ZE551ML)
Android 6.0.1, Android 5.0
I will add more information about devices when it appears.

SoLoader ZipException: Not a zip archive

Hi,
We are getting a crash due to SoLoader, which is being used in our react-native app.
This is primarily happening for users on Android 5/6.
We are using SoLoader version 0.5.0

A significant amount of our users (>60k) are facing this issue.
Crash logs:

Caused by java.util.zip.ZipException: Not a zip archive
       at java.util.zip.ZipFile.readCentralDir(ZipFile.java:397)
       at java.util.zip.ZipFile.(ZipFile.java:175)
       at java.util.zip.ZipFile.(ZipFile.java:131)
       at com.facebook.soloader.ExtractFromZipSoSource$ZipUnpacker.(ExtractFromZipSoSource.java)
       at com.facebook.soloader.ApkSoSource$ApkUnpacker.(ApkSoSource.java)
       at com.facebook.soloader.ApkSoSource.makeUnpacker(ApkSoSource.java)
       at com.facebook.soloader.UnpackingSoSource.getSoStorePath(UnpackingSoSource.java)
       at com.facebook.soloader.UnpackingSoSource.getSoStorePath(UnpackingSoSource.java)
       at com.facebook.soloader.SoLoader.initSoSources(SoLoader.java)
       at com.facebook.soloader.SoLoader.init(SoLoader.java)
       at com.facebook.soloader.SoLoader.init(SoLoader.java)
       at com.facebook.soloader.SoLoader.init(SoLoader.java)
       at com.facebook.react.ReactInstanceManager.initializeSoLoaderIfNecessary(ReactInstanceManager.java)
       at com.facebook.react.ReactInstanceManager.(ReactInstanceManager.java)
       at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java)

Is anyone else also facing this? How do we resolve this?

D/ApkSoSource: not allowing consideration of ... deferring to libdir

Hi,

We are developing a GIS Application and we are using React Native to support both iOS and Android. Our company's primary GIS Provider is Esri and they provide both an iOS SDK and Android SDK for consuming their services. We have created a port to allow us to integrate their SDK with our RN project.

Our issue is that during the initial install of the Android application we are seeing the below error message which results in a white screen. The solution to this is to re-launch the application and the error goes away. I am unsure if the error is a problem with the Android SDK provided by Esri or ApkSoSource.

Any additional information that can be provided on why we are receiving this error would be greatly beneficial.

Thanks,
Jacob

Ref: https://community.esri.com/thread/246073-android-sdk-weird-behavior

D/ApkSoSource: not allowing consideration of lib/arm64-v8a/libc++_shared.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libfb.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libfolly_futures.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libfolly_json.so: deferring to libdir
D/ApkSoSource: not allowing consideration of lib/arm64-v8a/libglog.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libglog_init.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libimagepipeline.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libjsc.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libjscexecutor.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libjsijniprofiler.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libjsinspector.so: deferring to libdir
D/ApkSoSource: not allowing consideration of lib/arm64-v8a/libnative-filters.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libnative-imagetranscoder.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libreactnativeblob.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libreactnativejni.so: deferring to libdir
D/ApkSoSource: not allowing consideration of lib/arm64-v8a/libruntimecore.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libruntimecore_java.so: deferring to libdir
 not allowing consideration of lib/arm64-v8a/libyoga.so: deferring to libdir

Using SoLoader crashes because phone complains the lib is 32-bit

Hello. We have a app only ships armabi-v7a binaries. And rely on other abi's legacy support. But we have this crash log:

java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.p1.mobile.putong/lib-main/libsqlite3x.so" is 32-bit instead of 64-bit
    at java.lang.Runtime.load(Runtime.java:332)
    at java.lang.System.load(System.java:1069)
    at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:71)
    at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:42)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:299)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:247)
    at io.requery.android.database.sqlite.SQLiteDatabase.<clinit>(SQLiteDatabase.java:78)
    at com.p1.mobile.android.data.orm.DatabaseStore.db(DatabaseStore.java:111)
    at com.p1.mobile.android.data.orm.DatabaseStore.lambda$asyncFetch$52(DatabaseStore.java:334)
    at com.p1.mobile.android.data.orm.DatabaseStore.access$lambda$2(DatabaseStore.java)
    at com.p1.mobile.android.data.orm.DatabaseStore$$Lambda$3.run(DatabaseStore.java)
    at com.p1.mobile.android.app.Au.lambda$io$35(Au.java:183)
    at com.p1.mobile.android.app.Au.access$lambda$1(Au.java)
    at com.p1.mobile.android.app.Au$$Lambda$2.call(Au.java)
    at rx.Observable.unsafeSubscribe(Observable.java:8644)
    at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
    ... 7 more
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.p1.mobile.putong/lib-main/libsqlite3x.so" is 32-bit instead of 64-bit
    at java.lang.Runtime.load(Runtime.java:332)
    at java.lang.System.load(System.java:1069)
    at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:71)
    at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:42)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:299)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:247)
    at io.requery.android.database.sqlite.SQLiteDatabase.<clinit>(SQLiteDatabase.java:78)
    at com.p1.mobile.android.data.orm.DatabaseStore.db(DatabaseStore.java:111)
    at com.p1.mobile.android.data.orm.DatabaseStore.lambda$asyncFetch$52(DatabaseStore.java:334)
    at com.p1.mobile.android.data.orm.DatabaseStore.access$lambda$2(DatabaseStore.java)
    at com.p1.mobile.android.data.orm.DatabaseStore$$Lambda$3.run(DatabaseStore.java)
    at com.p1.mobile.android.app.Au.lambda$io$35(Au.java:183)
    at com.p1.mobile.android.app.Au.access$lambda$1(Au.java)
    at com.p1.mobile.android.app.Au$$Lambda$2.call(Au.java)
    at rx.Observable.unsafeSubscribe(Observable.java:8644)
    at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)

So using lib-main only happens if System loader failed. This error happens on a Lenovo z90-7 phone

SoLoader is not compatible with Android app bundles

We're seeing crashes in SoLoader in production when loading libreactnativejni.so. We're using React Native 0.59 and SoLoader 0.6.0.

The crash occurs on a range of devices, on Android OS versions 6 through 10. Google devices seem especially prone, notably the Pixel and Chromebook Plus V2.

The crashes appear to stem from our switch to using an app bundle rather than an APK on the Google Play store. This looks possibly related to #30, but that issue is marked as resolved in 0.6.0.

It looks like the app is sometimes attempting to link against old copies of some of the libraries. Here are some examples:

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: dlopen failed: cannot locate symbol "_ZN3fLI7FLAGS_vE" referenced by "/data/app/com.fanduel.android.self-1/lib/arm/libglog.so"...

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: dlopen failed: cannot locate symbol "_ZN8facebook5react15makeJIntOrThrowEx" referenced by "/data/app/com.fanduel.android.self-7bFAALdOGMNizGU2gL_5nA==/lib/arm/libreactnativejni.so"...

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: dlopen failed: library "/data/user/0/com.fanduel.android.self/lib-0/libreactnativejni.so" not found

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: dlopen failed: library "libfb.so" not found

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libfb.so caused by: dlopen failed: library "/data/user/0/com.fanduel.android.self/lib-0/libfb.so" not found

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libfb.so caused by: couldn't find DSO to load: libc++_shared.so caused by: dlopen failed: "/data/data/com.fanduel.android.self/lib-1/libc++_shared.so" is 32-bit instead of 64-bit (this last one started appearing after we added 64-bit support)

I wonder if the problem is just that the filesystem sometimes isn't fully flushed and ends up in an inconsistent state. Inspecting the SoLoader code, it tries to be robust (e.g. comparing a manifest of extracted files against the contests of the APK zipfiles) but it's hard to say if it's bulletproof. Maybe the manifest file is updated, but the writes to the .so files aren't completed, so the app thinks it has the current libraries installed when in fact it still has the old ones.

Sorry for the lack of detail, I'm still trying to get a clearer picture of what's going on!
The crash rate is quite low and we haven't managed to reproduce it ourselves. However, I think I've seen enough to be confident that it's the combination of SoLoader and app bundles that causes the problem.

We plan to switch back to using an APK instead of an app bundle to see if that avoids the problem.

Could not initialize SoLoader fresco-1.13.0

Description

We have 5k+ crashes in Google Play Console and Crashlytics with the following error:

java.lang.RuntimeException: 
 at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5892)
 at android.app.ActivityThread.access$1100 (ActivityThread.java:200)
 at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1653)
 at android.os.Handler.dispatchMessage (Handler.java:106)
 at android.os.Looper.loop (Looper.java:193)
 at android.app.ActivityThread.main (ActivityThread.java:6694)
 at java.lang.reflect.Method.invoke (Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Caused by: java.lang.RuntimeException: 
 at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:76)
 at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:45)
 at com.myapp.Application.onCreate (Application.java:166)
 at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1155)
 at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5887)
Caused by: java.io.IOException: 
 at sun.nio.ch.FileDispatcherImpl.lock0 (Native Method)
 at sun.nio.ch.FileDispatcherImpl.lock (FileDispatcherImpl.java:115)
 at sun.nio.ch.FileChannelImpl.lock (FileChannelImpl.java:1097)
 at java.nio.channels.FileChannel.lock (FileChannel.java:1053)
 at com.facebook.soloader.FileLocker.<init> (FileLocker.java:38)
 at com.facebook.soloader.FileLocker.lock (FileLocker.java:31)
 at com.facebook.soloader.UnpackingSoSource.prepare (UnpackingSoSource.java:417)
 at com.facebook.soloader.SoLoader.initSoSources (SoLoader.java:304)
 at com.facebook.soloader.SoLoader.init (SoLoader.java:181)
 at com.facebook.soloader.SoLoader.init (SoLoader.java:164)
 at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:68)

Reproduction

I can't reproduce this crash on all my devices and emulators.
We use fresco:1.13.0 and imagepipeline-okhttp3:1.13.0

Application.java:

OkHttpClient.Builder ohcb = new OkHttpClient.Builder()
        .addInterceptor(new Interceptor() {
            @Override
            public Response intercept(Chain chain) throws IOException {
                Request.Builder ongoing = chain.request().newBuilder();

                ongoing.addHeader("X-device", "android");
                // etc..

                return chain.proceed(ongoing.build());
            }
        });

ImagePipelineConfig imagePipelineConfig = OkHttpImagePipelineConfigFactory
        .newBuilder(this, ohcb.build())
        .build();
Fresco.initialize(this, imagePipelineConfig);

Additional Information

  • Fresco version: 1.13.0
  • androidx
  • okhttp: 3.12.1

Google Play Console says that the error is only on android 9.0, but in crashlytics I have this:

Screenshot 2019-05-15 19 02 50

Google Play Console:

Screenshot 2019-05-15 19 09 32

Failing to load libhermes.so on Chromebooks

Description

Recently we started using SoLoader version 0.8.0 to fix an issue with the hermes engine not loading on some phones like the Oppo. However after this fix we are seeing a new error that seems to only be affecting Chromebooks running our react native application.

Fatal Exception: java.lang.UnsatisfiedLinkError
couldn't find DSO to load: libhermes.so caused by: APK was built for a different platform

com.facebook.soloader.SoLoader.doLoadLibraryBySoName (SoLoader.java:789)
com.facebook.soloader.SoLoader.loadLibraryBySoName (SoLoader.java:639)
com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:577)
com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:525)
com.facebook.hermes.reactexecutor.HermesExecutor.<clinit> (HermesExecutor.java:20)
com.facebook.hermes.reactexecutor.HermesExecutorFactory.create (HermesExecutorFactory.java:27)
com.facebook.react.ReactInstanceManager$5.run (ReactInstanceManager.java:949)

Platforms

Although we are unable to reproduce the error it appears to happen on android versions 5-9 and only on Chromebooks with the majority being the Google Chromebook 11 Model 3180.

Gradle

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 19
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
    playServicesVersion = "17.0.0"
    googlePlayServicesAuthVersion = "16.0.1" // <--- use this version or newer
}


buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            url 'https://maven.fabric.io/public'
        }
        google()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.4.2')
        classpath("com.google.gms:google-services:4.0.1")
        classpath("com.jaredsburrows:gradle-license-plugin:0.8.41")
        classpath("embrace-io:embrace-swazzler:3.4.1")
        classpath('io.fabric.tools:gradle:1.28.1')
        classpath('com.google.firebase:perf-plugin:1.3.1')
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        configurations.all {
            resolutionStrategy {
                force "com.facebook.soloader:soloader:0.8.0"
            }
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                // Note: order matters here, start with the most generic library, in this case the
                // android gms, and then change more specific packages below.
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion rootProject.ext.playServicesVersion
                }
                if (requested.name == 'firebase-iid') {
                    details.useVersion '20.0.1'
                }
                if (requested.name == 'play-services-vision') {
                    details.useVersion '17.0.2'
                }
                if (requested.name == 'play-services-vision-common') {
                    details.useVersion '17.0.2'
                }
                if (requested.name == 'play-services-vision-image-label') {
                    details.useVersion '17.0.2'
                }
                if (requested.group == 'com.android.support') {
                    if (!requested.name.startsWith("multidex")) {
                        details.useVersion "${rootProject.ext.supportLibVersion}"
                    }
                }
            }
        }
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}
    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
        def hermesPath = "../../node_modules/hermes-engine/android/"
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")

Library Versions

Note we have already looked into other similar PRs such as this, however we are building our app as an apk and not bundling.

  • SoLoader 0.8.0
  • react-native 0.60.5
  • hermes-engine ^0.1.1

App crashes after loading the so file, JNI DETECTED ERROR IN APPLICATION: JNI RegisterNatives called with pending exception java.lang.ExceptionInInitializerError

Hi,
I am trying to load the .so file from the app data directory, run into this problem after loading the so file,

ERROR

2019-05-16 18:48:38.286 5083-5083/com.sample.preprod D/SoLoader: libfb.so found on /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a
2019-05-16 18:48:38.286 5083-5083/com.sample.preprod D/SoLoader: Not resolving dependencies for libfb.so
2019-05-16 18:48:38.579 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475] JNI DETECTED ERROR IN APPLICATION: JNI RegisterNatives called with pending exception java.lang.ExceptionInInitializerError: 
2019-05-16 18:48:38.579 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String) (Runtime.java:-2)
2019-05-16 18:48:38.579 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-05-16 18:48:38.579 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.srikanth.soloader.com.facebook.soloader.SoLoader$1.load(java.lang.String, int) (SoLoader.java:360)
2019-05-16 18:48:38.579 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at int com.srikanth.soloader.com.facebook.soloader.DirectorySoSource.loadLibraryFrom(java.lang.String, int, java.io.File, android.os.StrictMode$ThreadPolicy) (DirectorySoSource.java:81)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at int com.srikanth.soloader.com.facebook.soloader.DirectorySoSource.loadLibrary(java.lang.String, int, android.os.StrictMode$ThreadPolicy) (DirectorySoSource.java:54)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.srikanth.soloader.com.facebook.soloader.SoLoader.doLoadLibraryBySoName(java.lang.String, int, android.os.StrictMode$ThreadPolicy) (SoLoader.java:720)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at boolean com.srikanth.soloader.com.facebook.soloader.SoLoader.loadLibraryBySoName(java.lang.String, java.lang.String, java.lang.String, int, android.os.StrictMode$ThreadPolicy) (SoLoader.java:630)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at boolean com.srikanth.soloader.com.facebook.soloader.SoLoader.loadLibrary(java.lang.String, int) (SoLoader.java:568)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at boolean com.srikanth.soloader.com.facebook.soloader.SoLoader.loadLibrary(java.lang.String) (SoLoader.java:516)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.android.sample.ui.sample.activities.GameRNActivity.loadNativeLibrary(com.android.sample.ui.tasks.TaskParam) (GameRNActivity.java:298)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.android.sample.ui.sample.activities.GameRNActivity.updateTheDownloadStatus(android.content.Intent) (GameRNActivity.java:135)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.android.sample.ui.sample.activities.GameRNActivity.access$000(com.android.sample.ui.sample.activities.GameRNActivity, android.content.Intent) (GameRNActivity.java:43)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.android.sample.ui.sample.activities.GameRNActivity$1.onReceive(android.content.Context, android.content.Intent) (GameRNActivity.java:112)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void android.app.LoadedApk$ReceiverDispatcher$Args.run() (LoadedApk.java:1128)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:754)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void android.os.Looper.loop() (Looper.java:163)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6238)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:933)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:823)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475] 
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]     in call to RegisterNatives
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]     from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475] "main" prio=5 tid=1 Runnable
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | group="main" sCount=0 dsCount=0 obj=0x745832a8 self=0xec704400
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | sysTid=5083 nice=-10 cgrp=default sched=0/0 handle=0xef3d3538
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | state=R schedstat=( 4712645395 443995441 3704 ) utm=401 stm=70 core=0 HZ=100
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | stack=0xff778000-0xff77a000 stackSize=8MB
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | held mutexes= "mutator lock"(shared held)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #00 pc 00352411  /system/lib/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+128)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #01 pc 00332569  /system/lib/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+308)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #02 pc 0023a825  /system/lib/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+848)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #03 pc 0023ad47  /system/lib/libart.so (_ZN3art9JavaVMExt9JniAbortVEPKcS2_St9__va_list+58)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #04 pc 000cb09b  /system/lib/libart.so (_ZN3art11ScopedCheck6AbortFEPKcz+46)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #05 pc 000cac87  /system/lib/libart.so (_ZN3art11ScopedCheck11CheckThreadEP7_JNIEnv+362)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #06 pc 000c9c9f  /system/lib/libart.so (_ZN3art11ScopedCheck22CheckPossibleHeapValueERNS_18ScopedObjectAccessEcNS_12JniValueTypeE+26)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #07 pc 000c917b  /system/lib/libart.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE+802)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #08 pc 000c678d  /system/lib/libart.so (_ZN3art8CheckJNI15RegisterNativesEP7_JNIEnvP7_jclassPK15JNINativeMethodi+464)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #09 pc 0000d90b  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (_ZN8facebook3jni15CountableOnLoadEP7_JNIEnv+62)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #10 pc 000153d9  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (_Z16initialize_fbjniv+8)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #11 pc 000132b7  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (_ZN8facebook3jni10initializeEP7_JavaVMONSt6__ndk18functionIFvvEEE+90)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #12 pc 00017829  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (JNI_OnLoad+32)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #13 pc 0023c835  /system/lib/libart.so (_ZN3art9JavaVMExt17LoadNativeLibraryEP7_JNIEnvRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEP8_jobjectP8_jstringPS9_+1844)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #14 pc 00003167  /system/lib/libopenjdkjvm.so (JVM_NativeLoad+178)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #15 pc 00068c6d  /system/framework/arm/boot.oat (Java_java_lang_Runtime_nativeLoad__Ljava_lang_String_2Ljava_lang_ClassLoader_2Ljava_lang_String_2+144)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.Runtime.nativeLoad(Native method)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.reflect.Method.invoke!(Native method)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.srikanth.soloader.com.facebook.soloader.SoLoader$1.load(SoLoader.java:360)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   - locked <0x0ae5e715> (a java.lang.Runtime)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.srikanth.soloader.com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:81)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.srikanth.soloader.com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:54)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.srikanth.soloader.com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:720)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.srikanth.soloader.com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:630)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   - locked <0x0f89fa2a> (a java.lang.Object)
2019-05-16 18:48:38.580 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.srikanth.soloader.com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:568)
2019-05-16 18:48:38.581 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.srikanth.soloader.com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:516)
2019-05-16 18:48:38.581 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.android.sample.ui.sample.activities.GameRNActivity.loadNativeLibrary(GameRNActivity.java:298)
2019-05-16 18:48:38.581 5083-5083/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.android.sample.ui.sample.activities.GameRNActivity.updateTheDownloadStatus(GameRNActivity.java:135)

complete log

Manifest merger failed: Duplicate package name

When adding soloader 0.8.0 my build fails with an error in the manifest merger:

[com.facebook.soloader:soloader:0.8.0] /home/ph1b/.gradle/caches/transforms-2/files-2.1/8f085a1fa1db60fbcb92924ed2143bb2/jetified-soloader-0.8.0/AndroidManifest.xml Error:
	Package name 'com.facebook.soloader' used in: com.facebook.soloader:soloader:0.8.0, com.facebook.soloader:annotation:0.8.0.
/home/ph1b/repos/SoLoaderBug/app/src/main/AndroidManifest.xml Error:
	Validation failed, exiting

This is because I followed the advise from: https://developer.android.com/studio/releases/gradle-plugin:

The correct usage of unique package names are currently not enforced but will become more strict on later versions of the plugin. On Android Gradle plugin version 3.4.0, you can opt-in to check whether your project declares acceptable package names by adding the line below to your gradle.properties file.

android.uniquePackageNames = true

It would be great if you gave the annotations artifact a proper unique package name.

soloader caused Application not responding

Description
I called below code:

ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
.setDownsampleEnabled(true)
.build();

Fresco.initialize(context, config);
and got below ANR:
java.util.regex.Matcher in openImpl
java.util.regex.Matcher in usePattern at line 238
java.util.regex.Matcher in at line 89
java.util.regex.Pattern in matcher at line 297
com.facebook.soloader.ExtractFromZipSoSource$ZipUnpacker in ensureDsos at line 79
com.facebook.soloader.ExtractFromZipSoSource$ZipUnpacker in getDsoManifest at line 137
com.facebook.soloader.UnpackingSoSource in refreshLocked at line 324
com.facebook.soloader.UnpackingSoSource in prepare at line 420
com.facebook.soloader.SoLoader in initSoSources at line 266
com.facebook.soloader.SoLoader in init at line 170
com.facebook.soloader.SoLoader in init at line 153
com.facebook.drawee.backends.pipeline.Fresco in initialize at line 61
com.facebook.drawee.backends.pipeline.Fresco in initialize at line 44
com.mycompany.FrescoImageView in init at line 294

Another kind of ANR stacktrace is:
libcore.io.Posix in fsync
libcore.io.BlockGuardOs in fsync at line 143
java.io.FileDescriptor in sync at line 74
com.facebook.soloader.UnpackingSoSource in writeState at line 176
com.facebook.soloader.UnpackingSoSource in refreshLocked at line 321
com.facebook.soloader.UnpackingSoSource in prepare at line 420
com.facebook.soloader.SoLoader in initSoSources at line 266
com.facebook.soloader.SoLoader in init at line 170
com.facebook.soloader.SoLoader in init at line 153
com.facebook.drawee.backends.pipeline.Fresco in initialize at line 61
com.facebook.drawee.backends.pipeline.Fresco in initialize at line 44
com.mycompany.FrescoImageView in init at line 294

Reproduction
It is an online ANR, I can't reproduce it on my phone, however it happens more than 100 times per day.

Solution
N/A

Additional Information
Fresco version: 1.10.0
Platform version: from 4.4 to 9.0

btw, I moved the issue from fresco to soloader.

No static method loadLibrary in class

(Hi @passy, if you're reading this, good to 'see' you again.)

This was previously reported in #10. I get https://pastebin.com/R5zfJtNn when starting up our app. Occurs with 0.5.0 and also with 0.4.1, but not with 0.3.0. Rebooting the Mac, as advised in that issue, did not help. We didn't attempt running with Windows.

Repro steps:

Our app had been running fine with SoLoader 0.4.1 and Fresco 1.9.0. We were doing a lazy-init of SoLoader; it is initialized by Fresco, and we didn't initialize Fresco until loading the first view with an image.

Lately we tried to add Sonar to the app. This requires calling SoLoader.init directly in the Application.onCreate method. This craps out.

The workaround is to downgrade to 0.3.0, but hopefully this can be fixed long term.

license question

I saw the Facebook updated the license for React to MIT, but this project still has BSD-3-Clause and the additional patent terms. Are you going to update this project to MIT as well?

FileNotFoundException when initializing SoLoader on devices with Android 6

I'm using Fresco in my project and initialize it in Application.onCreate(). During initialization Fresco initilizes SoLoader, and in some cases SoLoader initialization fails with FileNotFoundException. Unfortunately, I have no idea how to reproduce this crash but according to Google Play Console that's one of the most popular crashes for my app. And it happens on Android 6 only.

java.lang.RuntimeException: 
  at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:65)
  at com.example.MyApplication.onCreate (MyApplication.java:135)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1018)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4970)
  at android.app.ActivityThread.-wrap1 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1560)
  at android.os.Handler.dispatchMessage (Handler.java:111)
  at android.os.Looper.loop (Looper.java:207)
  at android.app.ActivityThread.main (ActivityThread.java:5765)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)
Caused by: java.io.FileNotFoundException: 
  at libcore.io.IoBridge.open (IoBridge.java:487)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:87)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:72)
  at com.facebook.soloader.FileLocker.<init> (FileLocker.java:28)
  at com.facebook.soloader.FileLocker.lock (FileLocker.java:24)
  at com.facebook.soloader.UnpackingSoSource.prepare (UnpackingSoSource.java:393)
  at com.facebook.soloader.SoLoader.initImpl$230dc011 (SoLoader.java:211)
  at com.facebook.soloader.SoLoader.init (SoLoader.java:120)
  at com.facebook.soloader.SoLoader.init$1a54e370 (SoLoader.java:104)
  at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:63)
  at com.example.MyApplication.onCreate (MyApplication.java:135)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1018)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4970)
  at android.app.ActivityThread.-wrap1 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1560)
  at android.os.Handler.dispatchMessage (Handler.java:111)
  at android.os.Looper.loop (Looper.java:207)
  at android.app.ActivityThread.main (ActivityThread.java:5765)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)
Caused by: android.system.ErrnoException: 
  at libcore.io.Posix.open (Posix.java)
  at libcore.io.BlockGuardOs.open (BlockGuardOs.java:186)
  at libcore.io.IoBridge.open (IoBridge.java:473)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:87)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:72)
  at com.facebook.soloader.FileLocker.<init> (FileLocker.java:28)
  at com.facebook.soloader.FileLocker.lock (FileLocker.java:24)
  at com.facebook.soloader.UnpackingSoSource.prepare (UnpackingSoSource.java:393)
  at com.facebook.soloader.SoLoader.initImpl$230dc011 (SoLoader.java:211)
  at com.facebook.soloader.SoLoader.init (SoLoader.java:120)
  at com.facebook.soloader.SoLoader.init$1a54e370 (SoLoader.java:104)
  at com.facebook.drawee.backends.pipeline.Fresco.initialize (Fresco.java:63)
  at com.example.MyApplication.onCreate (MyApplication.java:135)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1018)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4970)
  at android.app.ActivityThread.-wrap1 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1560)
  at android.os.Handler.dispatchMessage (Handler.java:111)
  at android.os.Looper.loop (Looper.java:207)
  at android.app.ActivityThread.main (ActivityThread.java:5765)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)

SoLoader can't find .so deps when app is packaged as Prebuilt APK with Android AOSP Source

Thanks so much for the hard work here!

I have a unique situation that perhaps you can shed some light on!

I am building a React Native Android application that will ship with an Android Device, and therefore it's being included in the AOSP build process as a prebuilt APK.

When I install the APK via ADB, it runs great! However, when I build the Android source including the App, I flash the device, and see the App on the homescreen. However, when it boots, I see the following logs from SoLoader:

01-08 06:20:53.366 2950-2997/com.lightos D/SoLoader: Loading lib dependencies: [libglog_init.so, libyoga.so, libprivatedata.so, libfb.so, libfolly_json.so, libjsc.so, libglog.so, libgnustl_shared.so, libandroid.so, liblog.so, libstdc++.so, libm.so, libc.so, libdl.so]
    About to load: libglog_init.so
01-08 06:20:53.368 695-717/? D/ActivityTrigger: ActivityTrigger activityStopTrigger 
01-08 06:20:53.373 3430-3514/? W/Adreno-ES20: <core_glFinish:34>: glFinish skipped: 0
01-08 06:20:53.376 3430-3514/? W/Adreno-ES20: <core_glFinish:34>: glFinish skipped: 0
01-08 06:20:53.465 2950-2997/com.lightos D/SoLoader: Loading lib dependencies: [libglog.so, libgnustl_shared.so, liblog.so, libstdc++.so, libm.so, libc.so, libdl.so]
    About to load: libglog.so
01-08 06:20:53.515 2950-2997/com.lightos D/SoLoader: Loading lib dependencies: [libgnustl_shared.so, libstdc++.so, libm.so, libc.so, libdl.so]
01-08 06:20:53.516 2950-2997/com.lightos D/SoLoader: About to load: libgnustl_shared.so
01-08 06:20:53.550 2950-2997/com.lightos D/SoLoader: Loading lib dependencies: [libm.so, libc.so, libdl.so]
    About to load: libm.so
01-08 06:20:53.551 2950-2997/com.lightos D/SoLoader: libm.so not found on /data/data/com.lightos/lib-main
    Result 0 for libm.so in source com.facebook.soloader.ApkSoSource[root = /data/data/com.lightos/lib-main flags = 1]
    Extraction logs: null
01-08 06:20:53.552 2950-2997/com.lightos D/SoLoader: libm.so not found on /vendor/lib
    Result 0 for libm.so in source com.facebook.soloader.DirectorySoSource[root = /vendor/lib flags = 2]
01-08 06:20:53.553 2950-2997/com.lightos D/SoLoader: Loaded: libm.so
01-08 06:20:53.554 2950-2997/com.lightos D/SoLoader: About to load: libc.so
    libc.so not found on /data/data/com.lightos/lib-main
01-08 06:20:53.555 2950-2997/com.lightos D/SoLoader: Result 0 for libc.so in source com.facebook.soloader.ApkSoSource[root = /data/data/com.lightos/lib-main flags = 1]
01-08 06:20:53.556 2950-2997/com.lightos D/SoLoader: Extraction logs: null
    libc.so not found on /vendor/lib
01-08 06:20:53.557 2950-2997/com.lightos D/SoLoader: Result 0 for libc.so in source com.facebook.soloader.DirectorySoSource[root = /vendor/lib flags = 2]
    Loaded: libc.so
01-08 06:20:53.558 2950-2997/com.lightos D/SoLoader: About to load: libdl.so
    libdl.so not found on /data/data/com.lightos/lib-main
01-08 06:20:53.559 2950-2997/com.lightos D/SoLoader: Result 0 for libdl.so in source com.facebook.soloader.ApkSoSource[root = /data/data/com.lightos/lib-main flags = 1]
    Extraction logs: null
01-08 06:20:53.560 2950-2997/com.lightos D/SoLoader: libdl.so not found on /vendor/lib
    Result 0 for libdl.so in source com.facebook.soloader.DirectorySoSource[root = /vendor/lib flags = 2]
    Loaded: libdl.so
01-08 06:20:53.563 2950-2997/com.lightos E/SoLoader: Error when loading lib: dlopen failed: couldn't map "/data/data/com.lightos/lib-main/libgnustl_shared.so" segment 2: Permission denied
01-08 06:20:53.564 2950-2997/com.lightos E/SoLoader: Could not load: libgnustl_shared.so
    Could not load: libglog.so
    Could not load: libglog_init.so
01-08 06:20:53.565 2950-2997/com.lightos E/SoLoader: Could not load: libreactnativejni.so
01-08 06:20:53.570 2950-2997/com.lightos E/AndroidRuntime: FATAL EXCEPTION: Thread-2
    Process: com.lightos, PID: 2950
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:522)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:420)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:370)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:335)
        at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:18)
        at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:19)
        at com.facebook.react.bridge.JSCJavaScriptExecutorFactory.create(JSCJavaScriptExecutorFactory.java:21)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:917)
        at java.lang.Thread.run(Thread.java:764)
01-08 06:20:53.547 2950-2950/com.lightos W/Thread-2: type=1400 audit(0.0:74): avc: denied { execute } for path="/data/data/com.lightos/lib-main/libgnustl_shared.so" dev="mmcblk0p38" ino=2430 scontext=u:r:system_app:s0 tcontext=u:object_r:system_app_data_file:s0 tclass=file permissive=0

It appears to me that the install process that moves the .so files to the appropriate place on the Android filesystem isn't being run for the packaged app in the AOSP build step (but I have confirmed they are in the APK itself by unzipping and checking).

What should I do to get this working as an Android prebuilt?

Thank you!

SoLoader-0.1.0 build error

BUILD FAILED
Buck wasn't able to parse C:\cygwin64\home\shenrenhao\SoLoader-0.1.0\java\com\facebook\soloader\BUCK:
NameError: name 'project_config' is not defined
Call stack:
File "C:\cygwin64\home\shenrenhao\Soloader-0.1.0.buckd\resources\2019.05.06.01\buck_server\buck_parser\profiler.py", line 507, in wrapped
return func(*args, **kwargs)
File "C:\cygwin64\home\shenrenhao\SoLoader-0.1.0\java\com\facebook\soloader\BUCK", line 21
project_config(

This error happened while trying to get dependency '//java/com/facebook/soloader:soloader' of target '//:soloader'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.