Closed ferrannp closed 5 years ago
Please try to unzip your apk
and see what .so
it contains.
I have tried to enable Proguard on a small app, and the .so
is added correctly.
in soLoader lib changed api method signature loadLibrary():bool
instead of expected loadLibrary():void
... soLoader highest compatible lib version is 0.4.+
Solution is downgrade the Fresco and soLoader libs versions. 10.9.+
and 0.4.+
@OleksandrKucherenko Thanks for the suggestions.
@OleksandrKucherenko hello. I have these versions
compile 'com.facebook.fresco:fresco:1.9.0'
compile 'com.facebook.soloader:soloader:0.3.0'
android/app/build.gradle
android {
...
defaultConfig {
...
ndk {
abiFilters "armeabi-v7a", "x86"
}
...
}
splits {
abi {
...
include "armeabi-v7a", "x86"
...
}
}
...
}
apk contains 2 files librealmreact.so
in lib/armeabi-v7a and lib/x86
but it doesn't help to solve issue
09-17 10:10:09.619 10283 10304 E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:522)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:420)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:370)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:335)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at io.realm.react.RealmReactModule.<clinit>(RealmReactModule.java:59)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at io.realm.react.RealmReactPackage.createNativeModules(RealmReactPackage.java:31)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:109)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1175)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1145)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1086)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:116)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:916)
09-17 10:10:09.619 10283 10304 E AndroidRuntime: at java.lang.Thread.run(Thread.java:760)
2 @serjiogunit : it sounds like librealmreact.so
library is not a part of the final android binary.
Just use Android Studio feature ' analyze APK..." and check that inside the final binary librealmreact.so file exists. Also, analyze how proguard rename the classes, are they included into first DEX file or into second/third one.
next step is to validate which ABI used on the device... x64 vs x86, etc.
next step is to try to follow - https://github.com/facebook/fresco/issues/2049#issuecomment-375257032
I still have same issue with "react-native": "^0.57.7"
and "realm": "^2.21.0",
. @kneth I unzipped the .apk
, it seems the librealmreact.so
is there:
lib/armeabi-v7a/librealmreact.so
(there is only armeabi-v7a
in lib
folder)
But the error says:
2018-12-21 18:15:25.050 7434-7449/? E/SoLoader: couldn't find DSO to load: librealmreact.so caused by: Error: Cannot load /data/app/com.my.package-0uWDsr7mBpTMJ4J4ENo9cw==/lib/arm/librealmreact.so
Can be wrong path somehow? Any ideas?
Also experiencing the same issue with Realm 2.21.1 and React Native 0.57.8 when compiling with proguard.
I wonder if somebody tried this with R8 (that should deprecate proguard) ?
R8 is a new tool for code shrinking and obfuscation that replaces ProGuard. You can start using the preview version of R8 by including the following in your project’s gradle.properties file:
android.enableR8 = true
I'll have a lookie, see if anything changes. Just annoying really. Having to keep Realm at 2.2.20 as anything i have tried so far above that version gives this exact issue.
@ferrannp It says /lib/arm/librealmreact.so
instead of arm-v7a
. What Android device are you trying to run APK on?
Another suggestion might be that it could be related to App Bundles if you are shipping your app using that? Realm Java had a bug that could look similar to what you are seeing: https://github.com/realm/realm-java/issues/5977
Pretty much got the app to split with these filters -> "armeabi-v7a", "x86" Not currently using the new App Bundles feature. Also running tests on a Samsung Galaxy s7 Edge and Galaxy s5.
Yes I got the two splits two:
app-armeabi-v7a-release.apk
app-x86-release.apk
Without proguard is fine. It does not matter if you split or not, the resulted .apk
crashes.
Would be nice to see a fix for this as we can't upgrade without disabling proguard. @kneth Any resolution?
It might be a good time to switch to ReLinker.
@ferrannp Same issue here. Any solutions? What I wondered is why android load librealmreact.so from "xxx/lib/arm/" but not "xxx/lib/armeabi-v7a"?
Hi, I add "-keep class io.realm.react.**" into the file proguard-rules.pro. Now it runs well
Sadly that doesn't help :/ Have had that in my proguard rules file for a long while.
@8BallBomBom Below is my version of realm and tools Realm: 2.22.0 React Native: 0.57.2 React: 16.5.1 And build environment: compileSdkVersion = 27 buildToolsVersion = "27.0.3" minSdkVersion = 19 targetSdkVersion = 26 supportLibVersion = "27.1.1" Hope this will be helpful
Very close to what i'm running. Thanks, will have a mess :)
So I updated realm to 2.22.0
and the error seems to be gone. This is what I have now:
"react-native": "0.57.8",
"realm": "^2.22.0",
And I only had to add one line to my proguard-rules.pro
:
-keep class io.realm.react.util.SSLHelper
@adyanced your .apk will be smaller just with that line instead of the whole realm.react
.
@kneth did anything change that this is fixed? Anyway we can avoid extra line in proguard file? (or should be documented or added to the realm proguard itself?).
@ferrannp I think #2177 might have helped.
@cmelchior Do you know if we can get rid of that proguard line?
Any update on this? I can't build my application :disappointed:
Any update on this ? Getting the following error and app is crashing immediately after opening. Happening only for arm64-v8a apk
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703) at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455) at io.realm.react.RealmReactModule.
(RealmReactModule.java:56) at io.realm.react.RealmReactPackage.createNativeModules(RealmReactPackage.java:31) at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42) at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:40) at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1212) at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1182) at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1120) at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123) at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943) at java.lang.Thread.run(Thread.java:764)
@reachtokish We currently don't support 64 bit. You need to include 32 bit only. See for example https://github.com/realm/realm-js/issues/2221#issuecomment-482131628
react-native : "0.59.3"
Adding :
ndk { abiFilters "armeabi-v7a", "x86" }
To build.gradle defaultConfig fixed it for me.
I will close this issue because it is creating confusion. Realm works with proguard (see comments), what it does not work is 64bits yet.
Sorry i didn't get back but yes the issue i had was resolved by upgrading React Native and running clean builds.
So I updated realm to
2.22.0
and the error seems to be gone. This is what I have now:"react-native": "0.57.8", "realm": "^2.22.0",
And I only had to add one line to my
proguard-rules.pro
:-keep class io.realm.react.util.SSLHelper
@adyanced your .apk will be smaller just with that line instead of the whole
realm.react
.@kneth did anything change that this is fixed? Anyway we can avoid extra line in proguard file? (or should be documented or added to the realm proguard itself?).
If onlyenableProguardInReleaseBuilds = true
, then this setting is effective, it solved my problem
-keep class io.realm.react.util.SSLHelper
Simplest way to find the issue is, create an apk with debuggable enabled & run it over device while connected to android studio & check logcat, in there you will see which package/lib exactly you need to add in -keep.
Goals
Trying to build a production ready apk (Android).
Actual Results
App crashes if proguard is enabled (
def enableProguardInReleaseBuilds = true
).It crashes no matter if you split in several apks or only one.
This is my proguard config:
Version of Realm and Tooling