Sifir-io / react-native-tor

Tor Daemon and Socks5 client for React Native iOS and Android projects!
MIT License
101 stars 15 forks source link

Receiving "lib/x86/libsifir_android.so" not found on Android #27

Closed skyworms closed 3 years ago

skyworms commented 3 years ago

Has anyone else been getting the following error on Android?

2021-02-27 10:51:02.178 7202-7245/com.tortesting E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.tortesting, PID: 7202
    java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~1jAPhodAhDJ6Z1S42uLWyw==/com.tortesting-T_iHp4rwmtQQOdc8aE32kw==/lib/x86/libsifir_android.so" not found
        at java.lang.Runtime.load0(Runtime.java:939)
        at java.lang.System.load(System.java:1628)
        at com.reactnativetor.TorPackage.createNativeModules(TorPackage.kt:18)
        at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
        at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42)
        at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1347)
        at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1318)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1225)
        at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:131)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1016)
        at java.lang.Thread.run(Thread.java:923)

I added implementation files("../../node_modules/react-native-tor/android/libs/sifir_android.aar") to android/app/build.gradle, but is there an additional step I'm missing?

This is the code I'm using:

import React, {useEffect} from 'react';
import {SafeAreaView, StatusBar} from 'react-native';
import TorBridge from 'react-native-tor';
const tor = TorBridge();

const _init = async () => {
  try {
    await tor.startIfNotStarted();
    const target =
      'kciybn4d4vuqvobdl2kdp3r2rudqbqvsymqwg4jomzft6m6gaibaf6yd.onion:50001';
    const conn = await tor.createTcpConnection({target}, (data, err) => {
      if (err) {
        console.error('error sending msg', err);
        return;
      }
      console.log('recieved tcp msg', data);
    });

    try {
      await conn.write(
        '{ "id": 1, "method": "blockchain.scripthash.get_balance", "params": ["716decbe1660861c3d93906cb1d98ee68b154fd4d23aed9783859c1271b52a9c"] }\n',
      );
      await conn.write(
        '{ "id": 2, "method": "blockchain.scripthash.get_balance", "params": ["716decbe1660861c3d93906cb1d98ee68b154fd4d23aed9783859c1271b52a9c"] }\n',
      );
    } catch (err) {
      console.error('Error SendingTcpMSg', err);
    }
  } catch (err) {
    console.log(err);
  }
};

const App: () => React$Node = () => {
  useEffect(() => {
    _init();
  }, []);
  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView />
    </>
  );
};
export default App;

Steps To Reproduce:

1. react-native init tortesting
2. cd tortesting && npm i && npm i react-native-tor
3. Bump deployment target to 12.1 for iOS
4. cd ios && pod install && cd ../
5. Add implementation files("../../node_modules/react-native-tor/android/libs/sifir_android.aar") to android/app/build.gradle
6. Bump minSdkVersion version to 26 in android/build.gradle
7. Clean & Rebuild Android project
8. react-native run-android 
Overtorment commented 3 years ago

did u add implementation files("../../node_modules/react-native-tor/android/libs/sifir_android.aar") in android/app/build.gradle ?

skyworms commented 3 years ago

I did, yes. This was with a fresh react-native init project as well.

gabidi commented 3 years ago

@skyworms Thanks for filing the issue. Need a bit more info to help you out: Are you running this on a Simulator or device ? What model / Android version ? Is Pro-guard enabled for your project ? If so try applying this diff https://github.com/Sifir-io/sifir-rs-sdk/commit/853ec84f49e09c8f7aed72e9731e22f56860e139

skyworms commented 3 years ago
gabidi commented 3 years ago

Sorry for the delayed reply, What version/branch are you running ? Can you please post your Package.json ?

skyworms commented 3 years ago

Sure thing. I'm running v^0.1.6 from https://www.npmjs.com/package/react-native-tor.

My package.json:

{
  "name": "tortesting",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-tor": "^0.1.6"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/runtime": "^7.8.4",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^25.1.0",
    "eslint": "^6.5.1",
    "jest": "^25.1.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}
gabidi commented 3 years ago

Should be resolved in latest build

ZainaliSyed commented 2 years ago

@gabidi I am facing same issue , whereas .apk works fine in all android version as well but once I push y build play store( Android ) It started crashing on opening

Play Store app crash

I connected my phone to android studio and I am getting same issue in error logs

Overtorment commented 2 years ago

random thought: could it be the issue with x86 vs x64 arch not present or smth..?

ZainaliSyed commented 2 years ago

@Overtorment @gabidi Solution :

So the issue is with this line

so i had to insert this line insert

System.loadLibrary("sifir_android");

Commented System.load("${ai.nativeLibraryDir}/libsifir_android.so");

Screenshot 2022-05-26 at 2 21 22 PM