我已将React Native更新为0.60-RC2,使用Android Studio折射器迁移到AndroidX,并使用了此处提到的喷射器:https://github.com/react-native-community/discussions-and-proposals/issues/129
这样做之后,运行library "libjsc.so" not found
时收到错误react-native run-android
。运行发行版APK时出现相同的错误。
堆栈跟踪为:
06-24 15:55:01.823 8579 8656 E SoLoader: Error when loading lib: dlopen failed: library "libjsc.so" not found lib hash: 83f1717c1dc187d9f252a9f1fc66d430 search path is /data/app/com.jtv.testapp-4hvCKbqEmbyyOPykuQhm4Q==/lib/arm
06-24 15:55:01.823 8579 8656 E SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
06-24 15:55:01.825 8579 8656 E AndroidRuntime: FATAL EXCEPTION: create_react_context
06-24 15:55:01.825 8579 8656 E AndroidRuntime: Process: com.jtv.testapp, PID: 8579
06-24 15:55:01.825 8579 8656 E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at com.facebook.react.jscexecutor.JSCExecutor.<clinit>(JSCExecutor.java:19)
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:29)
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
06-24 15:55:01.825 8579 8656 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
我的package.json
是:
{
"name": "TestApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"@react-native-community/async-storage": "^1.2.0",
"@react-native-community/blur": "^3.3.1",
"@react-native-community/netinfo": "^1.2.3",
"@react-native-community/slider": "^1.0.4",
"axios": "^0.18.0",
"jetifier": "^1.4.0",
"native-base": "^2.10.0",
"prop-types": "^15.6.2",
"qs": "^6.6.0",
"react": "^16.8.6",
"react-native": "^0.60.0-rc.2",
"react-native-appsee": "^2.6.21",
"react-native-device-info": "^0.24.3",
"react-native-dialog": "^5.5.0",
"react-native-draggable-flatlist": "^1.1.7",
"react-native-elements": "^0.19.1",
"react-native-email": "^1.0.2",
"react-native-fast-image": "^5.1.2",
"react-native-gesture-handler": "^1.0.12",
"react-native-iap": "^2.4.0",
"react-native-image-picker": "^0.28.0",
"react-native-iphone-x-helper": "^1.2.0",
"react-native-keyboard-aware-scroll-view": "^0.8.0",
"react-native-kochava-tracker": "^1.1.0",
"react-native-linear-gradient": "^2.5.3",
"react-native-material-dropdown": "^0.11.1",
"react-native-modal": "^9.0.0",
"react-native-orientation": "^3.1.3",
"react-native-scrollable-tab-view": "^0.10.0",
"react-native-snap-carousel": "^3.7.5",
"react-native-super-grid": "^2.4.4",
"react-native-tab-view": "^1.3.1",
"react-native-underline-tabbar": "^1.3.6",
"react-native-vector-icons": "^6.1.0",
"react-native-video": "^4.3.1",
"react-native-webview": "^5.12.0",
"react-navigation": "^3.0.9",
"react-navigation-backhandler": "^1.2.0",
"react-redux": "^6.0.1",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/runtime": "^7.4.2",
"@react-native-community/eslint-config": "^0.0.3",
"babel-jest": "^24.5.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^5.15.3",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.5.1",
"jest": "^24.5.0",
"metro-react-native-babel-preset": "^0.53.1",
"react-devtools-core": "^3.6.0",
"react-test-renderer": "^16.8.6",
"remote-redux-devtools": "^0.5.16"
},
"jest": {
"preset": "react-native"
}
}
我的build.gradle
是:
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'FontAwesome.ttf', 'MaterialCommunityIcons.ttf' ]
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.jtv.testapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 29
versionName "0.0.1"
multiDexEnabled true
renderscriptTargetApi 29
renderscriptSupportModeEnabled true
ndk {
abiFilters "arm64-v8a", "x86_64","armeabi-v7a", "x86"
}
packagingOptions {
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
exclude "lib/arm64-v8a/libimagepipeline.so"
exclude "lib/arm64-v8a/librealm-jni.so"
}
}
signingConfigs {
release {
if (project.hasProperty('RELEASE_STORE_FILE')) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':react-native-webview')
implementation project(':react-native-jtv-comic-reader')
//implementation project(':@react-native-community_slider')
implementation project(':@react-native-community_blur')
implementation project(':@react-native-community_async-storage')
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-appsee')
// implementation project(':react-native-tune-sdk')
implementation project(':react-native-iap')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-video')
implementation project(':react-native-vector-icons')
implementation project(':react-native-orientation')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-kochava-tracker')
// implementation project(':react-native-flurry-analytics')
implementation project(':react-native-device-info')
// implementation project(':react-native-fbsdk')
implementation project(':react-native-fast-image')
implementation project(':react-native-image-picker')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.facebook.fresco:fresco:1.13.0'
implementation 'com.facebook.fresco:animated-gif:1.13.0'
implementation 'androidx.mediarouter:mediarouter:1.0.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.11.2'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.android.installreferrer:installreferrer:1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.36.1'
implementation 'com.swrve.sdk.android:swrve-firebase:6.0.1'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
implementation 'androidx.mediarouter:mediarouter:1.0.0'
implementation 'com.google.android.gms:play-services-cast:17.0.0'
implementation 'com.googlecode.android-query:android-query:0.25.9'
implementation 'com.google.android.gms:play-services-cast-framework:17.0.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
什么是libjsc.so
文件?如何解决此错误?
答案 0 :(得分:3)
在您的app / build.gradle中添加以下内容
//在文件
的顶部上def useIntlJsc = false
//在依赖项
内部 if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+'
} else {
implementation 'org.webkit:android-jsc:+'
}
答案 1 :(得分:1)
为我解决的是将build.gradle更新packagingOptions
到:
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86/libjsc.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libjsc.so'
}
答案 2 :(得分:1)
我遇到了这个错误的轻微变化,在我的gradle配置中添加了第三个buildType'releaseStaging'
此实例中的解决方法是将以下行添加到app / build.gradle中的依赖项
releaseStagingImplementation files(hermesPath + "hermes-release.aar")
答案 3 :(得分:0)
我也有这个问题。我需要更新 build.gradle 文件中的 jscFlavor
变量:
def jscFlavor = 'org.webkit:android-jsc:+'
为此:
def jscFlavor = 'org.webkit:android-jsc-intl:+'
干杯。
答案 4 :(得分:-1)
就我而言,此错误与react-native-screen有关,并添加了以下内容 在android / app / build.gradle中的依存关系部分下面两行为我解决了该问题
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'