Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Crashes (starts for a fraction of second) after installing 'react-native-tor' even if I don't import anything from it. #33

Closed
cypher-nullbyte opened this issue Jul 3, 2021 · 16 comments

Comments

@cypher-nullbyte
Copy link

cypher-nullbyte commented Jul 3, 2021

I installed react-native-tor and then tried to use it.
image

When i run, npx react-native run-android. It ran then the app crashed right after loading on adb emulator.

Then I even removed the 'react-native-tor' and it ran without any issue.
Once I installed this library again, it crahsed again ( I even didn't use this library anywhere).

I think this issue is similar : #30

May anyone look into it and figure out whats going on.

@gabidi
Copy link
Contributor

gabidi commented Jul 3, 2021

Hi there, a bit more context is needed please.
Which version or branch are you running ? And can you provide adb logcat 's output just before the crash.

@cypher-nullbyte
Copy link
Author

cypher-nullbyte commented Jul 4, 2021


At around 9:31:15 i ran npx react-native run-android. At 31:21 around it ran in android and crashed instantly.
I'll be ready to provide any info to tackle this deadlock.
I didn't even import anything from 'react-native-tor'. Please, look into it. I learned react native only after seeing this library. I'm also trying.

07-04 09:31:21.223 5103 5135 D SoLoader: libreactnativejni.so not found on /data/user/0/com.shoppinglist/lib-main
07-04 09:31:21.223 5103 5135 D SoLoader: libreactnativejni.so found on /data/app/~~r7kRfI7f7dCPJwJdV1y2Sw==/com.shoppinglist-saGSfeES9jhZD-29uDgrGA==/lib/x86
07-04 09:31:21.223 5103 5135 D SoLoader: Not resolving dependencies for libreactnativejni.so
07-04 09:31:21.223 5103 5135 D SoLoader: Loaded: libreactnativejni.so
07-04 09:31:22.594 305 305 D goldfish-address-space: claimShared: Ask to claim region [0x3f7138000 0x3f71bb000]
--------- beginning of crash
07-04 09:31:23.679 5103 5152 E AndroidRuntime: FATAL EXCEPTION: create_react_context
07-04 09:31:23.679 5103 5152 E AndroidRuntime: Process: com.shoppinglist, PID: 5103
07-04 09:31:23.679 5103 5152 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~r7kRfI7f7dCPJwJdV1y2Sw==/com.shoppinglist-saGSfeES9jhZD-29uDgrGA==/lib/x86/libsifir_android.so" not found
07-04 09:31:23.679 5103 5152 E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:939)
07-04 09:31:23.679 5103 5152 E AndroidRuntime: at java.lang.System.load(System.java:1628)
07-04 09:31:23.679 5103 5152 E AndroidRuntime: at com.reactnativetor.TorPackage.createNativeModules(TorPackage.kt:18)
07-04 09:31:23.679 5103 5152 E AndroidRuntime: at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)

@cypher-nullbyte
Copy link
Author

cypher-nullbyte commented Jul 4, 2021

I tried running all options, for 5 hours. I tried for 'main', 'feat-hs', locally. Also installing using npm. I've seen the code.

  1. I first tried running the example from react-native-tor-feat-hs and imported this branch locally. But it had issues with gradle version and all.
  2. Then I created my own app, putting App.jsx from /example/scr. Didn't work.
  3. I also tried other possiblity(ies). I just created a simple rn-app and installed 'react-native-tor' from npm. It crashed here also.
    After running npm remove react-native-tor it continued to work.

@gabidi
Copy link
Contributor

gabidi commented Jul 4, 2021

From your error log :

07-04 09:31:23.679 5103 5152 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~r7kRfI7f7dCPJwJdV1y2Sw==/com.shoppinglist-saGSfeES9jhZD-29uDgrGA==/lib/x86/libsifir_android.so" not found

Just to confirm ? Did you complete this step from the README

    Link libs

    Android: open android/app/build.gradle and add

    implementation files("../../node_modules/react-native-tor/android/libs/sifir_android.aar")

@cypher-nullbyte
Copy link
Author

I tried it too, I put the above line in /android/app/build.gradle inside dependencies:{...}.
But I got this error:
image
Then I changed minSdk to 26.
image

It didn't threw error. but nothing happened.
It build successfully and smoothly. But right after launching it crashed.

I'm builing again and sending you the adb logcat 's output just before the crash in this context.
In previous adb logcat's output i didn't added this implementation file though

@cypher-nullbyte
Copy link
Author

cypher-nullbyte commented Jul 4, 2021

07-04 18:37:52.842 317 362 D goldfish-address-space: claimShared: Ask to claim region [0x3f6520000 0x3f65a3000]
--------- beginning of crash
07-04 18:37:53.954 6993 7040 E AndroidRuntime: FATAL EXCEPTION: create_react_context
07-04 18:37:53.954 6993 7040 E AndroidRuntime: Process: com.shoppinglist, PID: 6993
07-04 18:37:53.954 6993 7040 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~8SSmrpFVMgZLx0SMyXuZ7w==/com.shoppinglist-vLmld74qndRUCdVg0EQWcw==/lib/x86/libsifir_android.so" not found
07-04 18:37:53.954 6993 7040 E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:939)
07-04 18:37:53.954 6993 7040 E AndroidRuntime: at java.lang.System.load(System.java:1628)
07-04 18:37:53.954 6993 7040 E AndroidRuntime: at com.reactnativetor.TorPackage.createNativeModules(TorPackage.kt:18)
07-04 18:37:53.954 6993 7040 E AndroidRuntime: at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
07-04 18:37:53.954 6993 7040 E AndroidRuntime: at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42)


Notice : 07-04 18:37:53.954. Same problem :(

@cypher-nullbyte
Copy link
Author

cypher-nullbyte commented Jul 4, 2021

I think its all graddle version's wrong-doing.
image

I now tried one more thing, i took 'example' from 'main-branch' changed gradel version to 6.3 (the one given there was showing errors).
image
However, as u can see here it had issues with @babel. I'm trying within my capabilities, hope it gets fixed soon.


More info: I'm using JDK 14, Andoroid Studio 4.2.1

@cypher-nullbyte
Copy link
Author

cypher-nullbyte commented Jul 4, 2021

I am successfull in running the example given in your repo.
I changed the version of gradle to 6.3 in example.
I did npm install in example and root folder. There are lots of dependecy issues, we need to upgrade them (gradle version is the deal-breaker).
package [email protected] could not be installed (its showing platform specific, but it was shown optional).

However there is still no way out when it comes to comes to using it inside node_modules (by installing using npm [even locally])
I mean this fix will only work for the example inside the root project 'reactnativetor'.

@gabidi
Copy link
Contributor

gabidi commented Jul 4, 2021

Yeah changing the gradle & JDK version is not the way you want to go with RN as far as I know.
I just pushed a few commits this AM to HS branch in regards to how the .so is loaded. Try pulling the latest commits from feat/hs branch. I think that should resolve your loadlib error.

@cypher-nullbyte
Copy link
Author

cypher-nullbyte commented Jul 5, 2021

@gabidi it didn't work😖. MinSdk thing is resolved now (after your push).

I am feeling, it may work if I compile everything on my own [android part].
The only thing that works for me is example wrapped inide the 'react-native-tor' (that too after upgrading gradle to 6.3 exact).

You seem to be a pro in tech, I'm just a toddler.
may you guide me through ( I want to understand everything in this project by heart.)
I'll be talking in context of android.
---In android/libs/sifir_android.aar----

  • We've done c/c++ socket programming (implemented socks5 & proxy-server right ?) & got .sofile. We also have class files (of java) in the same folder.
  • What is the role of these java class files, are they simply bridging the static objects (inside libsifir_android.so) and the main project, i.e. kotlin package. Do you've source code libsifir_android.so. Or, you've referenced them from somewhere. May I have it plsss.

----We've used the above package (class files). In kotlin Project. Am I aprehending Right.

Did I apprehended the architecture of project properly?

I've not installed NDK, can the problem be due to that.
Thank u in adv.

@gabidi
Copy link
Contributor

gabidi commented Jul 5, 2021

The Readme answers most of the questions in regards to the stack , and yes, all parts of it are open source and links are included.
If there's something specific I can help you with do let me know :)

@cypher-nullbyte
Copy link
Author

[Few Fixes | Windows Only issue]:

I'm using windows. There's a problem when we eject our project from expo in order to use this native-library.

If someone gets this error:

Task :unimodules-react-native-adapter:compileDebugJavaWithJavac FAILED

The Fix is:
at node_modules/@unimodules/react-native-adapter/scripts/autolinking.gradle , at line 97:

'require("expo-modules-autolinking")(process.argv.slice(1))',
switch the quotes like this:
"require('expo-modules-autolinking')(process.argv.slice(1))",

sounds dumb, but expo is working on it [as of 6-7-21].

@gabidi : I've some urgency for a week. pls keep it open.

@gabidi
Copy link
Contributor

gabidi commented Jul 6, 2021

You can't use this package (or any other package that uses native code) in Expo.

@cypher-nullbyte
Copy link
Author

cypher-nullbyte commented Jul 6, 2021

Yes thats why I ejected.
Gradle versions are causing trouble.

Initially I had Jdk 14 ( gradle 6.3 works with it).
I could run the example in this repo after tweaking its version to 6.3.
(inside react-native-tor/example/android/gradle/wrapper/gradle-wrapper.properties

leaving the gradle version of main tor project to 6.1.1
(inside react-native-tor/android/gradle/wrapper/gradle-wrapper.properties)

But then I created new react-native-app {nothing with expo and all}.
I tried changing its version to 6.3 (as everything worked fine in the examle with these versions). I got this:
image

I also tried downloading jdk 16, but alas (we've to use gradle version-7 for that to work). It was also showing some errors while i tried using jdk 16 with gradle 7+ in your example too..

Which jdk version you used (jdk 11?). I don't know the exact cause, (graddle is just build automation thing).

@gabidi
Copy link
Contributor

gabidi commented Jul 17, 2021

FYI #36

@gabidi
Copy link
Contributor

gabidi commented Aug 2, 2021

Closing for no activity. Feel free to re-open if need be.

@gabidi gabidi closed this as completed Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants