Подтвердить что ты не робот

React native expection java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/{package}/lib-main/libgnustl_shared.so" 32-разрядный вместо 64-разрядного

Я пытаюсь интегрировать React Native с моим существующим Android-приложением. Я получаю следующее исключение, когда инициализация React Native Screen:

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.snapdeal.main/lib-main/libgnustl_shared.so" - это 32-разрядная версия вместо 64-разрядной

Приложение работает только на 64-битных устройствах.

В соответствии с моим обучением до сих пор я нашел этот вопрос в React Native Repo, но решение, предлагаемое в этом потоке, не помогает, поскольку я не использую какую-либо внешнюю библиотеку SO в существующем приложении.

Помимо вышеизложенного, я понял другое различие в структуре библиотеки на устройстве, где установлено мое приложение. Я сравниваю структуру моего приложения, а не обычного приложения для демонстрации.

React demo App

[email protected]_x86_64:**/data/data/com.react.demo/lib** # ls
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so

[email protected]_x86_64:/data/data/**com.react.demo**/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state

Мое приложение

[email protected]_x86_64:/data/data/**com.my.app**/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so

Разделяя несколько подробностей о моем проекте:

package.json

{
  "name": "projectname",
  "version": "1.0.0",
  "description": "Native NPM",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "Ishan D",
  "license": "ISC",
  "dependencies": {
    "react": "^15.3.2",
    "react-native": "^0.37.0",
    "react-native-linear-gradient": "^1.5.15",
    "rn-viewpager": "^1.1.3"
  },
  "devDependencies": {}
}

зависимости, используемые в родном проекте android

ext {
    compileSdkVersion = 24
    buildToolsVersion = '24.0.2'
    minSdkVersion = 16
    targetSdkVersion = 24
    supportLibrariesVersion = '23.0.1'
    playServiceVersion = '9.0.2'

    dep = [
            fabricPlugin          : 'io.fabric',
            fabricMavenUrl        : 'https://maven.fabric.io/public',
            fabricClasspath       : 'io.fabric.tools:gradle:1.+',

            playServiceClasspath  : 'com.google.gms:google-services:1.3.0-beta1',
            playServicePlugin     : 'com.google.gms.google-services',

            playServiceAppindexing: "com.google.android.gms:play-services-appindexing:$playServiceVersion",
            playServiceLocation   : "com.google.android.gms:play-services-location:$playServiceVersion",
            playServiceVision     : "com.google.android.gms:play-services-vision:$playServiceVersion",
            playServiceAuth       : "com.google.android.gms:play-services-auth:$playServiceVersion",
            playServiceBase       : "com.google.android.gms:play-services-base:$playServiceVersion",
            playServiceIdentity   : "com.google.android.gms:play-services-identity:$playServiceVersion",
            playServiceAnalytics  : "com.google.android.gms:play-services-analytics:$playServiceVersion",
            playServiceGcm        : "com.google.android.gms:play-services-gcm:$playServiceVersion",

            underCouchClasspath   : 'de.undercouch:gradle-download-task:2.0.0',
            underCouchPluigin     : 'de.undercouch.download',

            crashlytics           : 'com.crashlytics.sdk.android:crashlytics:[email protected]',

            moengage              : 'com.moengage:moe-android-sdk:6.0.29',

            supportV4             : "com.android.support:support-v4:$supportLibrariesVersion",
            supportAppCompatV7    : "com.android.support:appcompat-v7:$supportLibrariesVersion",
            supportCardviewV7     : "com.android.support:cardview-v7:$supportLibrariesVersion",
            supportDesignV7       : "com.android.support:design:$supportLibrariesVersion",

            okhttp                : 'com.squareup.okhttp:okhttp:2.5.0',
            junit                 : 'junit:junit:4.12',
            mockito               : 'org.mockito:mockito-core:1.10.19'
    ]
}

Любой ключ приветствуется.

PS: Я знаю, что response-native поддерживает 64-битные двоичные файлы, и я не использую какую-либо внешнюю библиотеку.

4b9b3361

Ответ 1

Добавьте следующее в файл app/gradle

defaultConfig {
....

    ndk {
        abiFilters "armeabi-v7a", "x86", 'armeabi', 'arm64-v8a'
    }

    packagingOptions {
        exclude "lib/arm64-v8a/libgnustl_shared.so"
    }
}

также убедитесь, что вы работаете с одним и тем же портом.

adb reverse tcp:8081 tcp:8081

Ответ 2

Это также может помочь вам: build.gradle (приложение)

android{
   ...
   defaultConfig {
      ....
      ndk {
        abiFilters "armeabi-v7a", "x86", 'armeabi', 'arm64-v8a'
      }
      packagingOptions {
               exclude "lib/arm64-v8a/libgnustl_shared.so"
               exclude '/lib/mips64/**'
               exclude '/lib/arm64-v8a/**'
               exclude '/lib/x86_64/**'
      }
      ...
   }
}

Ответ 3

React Native не предоставляет 64-битную версию собственного кода, и система всегда возвращается к 32-битной. Они решили эту проблему и планируют стать частью RN 0.59 release Ref: https://github.com/facebook/react-native/issues/2814#issuecomment-457644191

Ответ 4

Using RN 0.60.5 version.
If you guys are wondering why your app crashes if you download it from playstore, make the below changes

**packagingOptions {
exclude '/lib/mips64/'
exclude '/lib/arm64-v8a/'
exclude '/lib/x86_64/**'
//In pickFirst, replace the library name with the library that is causing error.
pickFirst '/lib/x86/libgnustl_shared.so' 
pickFirst '/lib/armeabi-v7a/libgnustl_shared.so'
}**

REASON - We are excluding all 64 bit libraries so that OS will not have confusion of which library to pick.

If you do not know which library is causing the crash, upload your bundle in Firebase test lab and then check. It will tell you which library is throwing the error