React Native:由于 SoLoader 问题,应用程序在启动时崩溃
Posted
技术标签:
【中文标题】React Native:由于 SoLoader 问题,应用程序在启动时崩溃【英文标题】:React Native: App crashes on start due to SoLoader issue 【发布时间】:2020-05-29 01:49:36 【问题描述】:我在 android 上的应用出现问题(ios 运行良好)。每次我进行构建时,当我打开应用程序时,它会在开始之前关闭。我已经尝试了许多我一直在 Github 和这里寻找的解决方案,但我还没有能够解决它。
安装是干净的,我检查了build.gradle
文件中的任何内容。
错误
02-13 11:56:31.627 7613 7613 D SoLoader: adding application source: com.facebook.soloader.DirectorySoSource[root = /data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86 flags = 0]
02-13 11:56:31.628 7613 7613 D SoLoader: adding backup source from : com.facebook.soloader.ApkSoSource[root = /data/data/com.bookinglayer.businessApp/lib-main flags = 1]
02-13 11:56:31.632 7613 7613 D SoLoader: Preparing SO source: com.facebook.soloader.DirectorySoSource[root = /data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86 flags = 0]
02-13 11:56:31.632 7613 7613 D SoLoader: Preparing SO source: com.facebook.soloader.ApkSoSource[root = /data/data/com.bookinglayer.businessApp/lib-main flags = 1]
02-13 11:56:31.632 7613 7613 V fb-UnpackingSoSource: locked dso store /data/user/0/com.bookinglayer.businessApp/lib-main
02-13 11:56:31.633 7613 7613 I fb-UnpackingSoSource: dso store is up-to-date: /data/user/0/com.bookinglayer.businessApp/lib-main
02-13 11:56:31.633 7613 7613 V fb-UnpackingSoSource: releasing dso store lock for /data/user/0/com.bookinglayer.businessApp/lib-main
02-13 11:56:31.718 7613 7613 D SoLoader: libjscexecutor.so not found on /data/data/com.bookinglayer.businessApp/lib-main
02-13 11:56:31.718 7613 7613 D SoLoader: libjscexecutor.so found on /data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86
02-13 11:56:31.916 7613 7634 D SoLoader: libreactnativejni.so not found on /data/data/com.bookinglayer.businessApp/lib-main
02-13 11:56:31.917 7613 7634 D SoLoader: libreactnativejni.so found on /data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86
02-13 11:56:32.019 7613 7634 D SoLoader: libfb.so not found on /data/data/com.bookinglayer.businessApp/lib-main
02-13 11:56:32.019 7613 7634 D SoLoader: libfb.so found on /data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86
02-13 11:56:32.045 1762 1762 E Layer : [Surface(name=AppWindowToken79aab0 token=Token5578df3 ActivityRecord5ebb862 u0 com.bookinglayer.businessApp/.MainActivity t123)/@0x9758047 - animation-leash#0] No local sync point found
02-13 11:56:32.045 1762 1762 E Layer : [Surface(name=AppWindowToken79aab0 token=Token5578df3 ActivityRecord5ebb862 u0 com.bookinglayer.businessApp/.MainActivity t123)/@0x9758047 - animation-leash#0] No local sync point found
02-13 11:56:32.073 7613 7634 D SoLoader: libfb.so not found on /data/data/com.bookinglayer.businessApp/lib-main
02-13 11:56:32.073 7613 7634 D SoLoader: libfb.so found on /data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86
02-13 11:56:32.073 7613 7634 I yer.businessAp: Thread[15,tid=7634,Native,Thread*=0xd3981a00,peer=0x18f5bb70,"create_react_context"] recursive attempt to load library "/data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86/libfb.so"
02-13 11:56:32.460 2048 2078 I ActivityTaskManager: Displayed com.bookinglayer.businessApp/.MainActivity: +990ms
02-13 11:56:32.639 7613 7637 D SoLoader: libyoga.so not found on /data/data/com.bookinglayer.businessApp/lib-main
02-13 11:56:32.639 7613 7637 D SoLoader: libyoga.so found on /data/app/com.bookinglayer.businessApp-mIjzUZ2SWw_f_dlNjdPM_Q==/lib/x86
02-13 11:56:33.282 7613 7637 E AndroidRuntime: Process: com.bookinglayer.businessApp, PID: 7613
02-13 11:56:33.283 2048 4712 W ActivityTaskManager: Force finishing activity com.bookinglayer.businessApp/.MainActivity
02-13 11:56:33.614 2048 4712 I ActivityManager: Process com.bookinglayer.businessApp (pid 7613) has died: cch CRE
build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn$productFlavor$buildType'
* // 'bundleIn$buildType'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn$productFlavor$buildType'
* // 'devDisabledIn$buildType'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of javascriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
android
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
defaultConfig
applicationId "com.bookinglayer.businessApp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 6
versionName "2.0.0"
splits
abi
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
signingConfigs
release
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE'))
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
buildTypes
release
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
// applicationVariants are e.g. debug, release
applicationVariants.all variant ->
variant.outputs.each output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
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
dependencies
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+"
implementation "androidx.appcompat:appcompat:1.0.0"
implementation 'org.webkit:android-jsc:+'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
if (enableHermes)
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
else
implementation jscFlavor
// 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 from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
package.json
"name": "business-app",
"version": "2.0.0",
"private": true,
"scripts":
"android:clean": "cd ./android && ./gradlew clean && cd ../",
"android:staging": "ENVFILE=.env.staging react-native run-android --variant=release",
"android:dev": "ENVFILE=.env.dev react-native run-android --variant=release",
"android:debug": "adb logcat | grep com.bookinglayer.businessApp ",
"android:beta:dev": "ENVFILE=.env.dev bundle exec fastlane android beta",
"android:beta:staging": "ENVFILE=.env.staging bundle exec fastlane android beta",
"android:release": "bundle exec fastlane android release",
"ios:staging": "ENVFILE=.env.staging react-native run-ios",
"ios:dev": "ENVFILE=.env.dev react-native run-ios",
"ios:beta:dev": "ENVFILE=.env.dev bundle exec fastlane ios beta",
"ios:beta:staging": "ENVFILE=.env.staging bundle exec fastlane ios beta",
"ios:release": "bundle exec fastlane ios release",
"e2e:build": "ENVFILE=.env.dev detox build",
"e2e:test": "ENVFILE=.env.dev detox test",
"start": "react-native start",
"test": "jest ./lib",
"lint": "eslint ./app ./lib",
"setup": "make install",
"postinstall": "npx jetify; react-native-port-patcher --new-port 8088",
"clean": "rm -rf ios/Podfile.lock && rm -rf ios/Pods/ && rm -rf /node-modules/ && rm -rf yarn.lock && rm -rf package-lock.json",
"clear-cache": "watchman watch-del-all && rm -rf node_modules/ && yarn install && react-native start --reset-cache",
"release": "semantic-release",
"prettier": "prettier --check \"**/*.js\"",
"link-assets": "npx react-native-asset",
"rename-fonts": "node ./renameFonts.js"
,
"dependencies":
"@react-native-community/async-storage": "^1.6.3",
"moment": "^2.24.0",
"native-base": "https://github.com/GeekyAnts/NativeBase.git#master",
"prop-types": "^15.7.2",
"react": "16.9.0",
"react-intl": "^3.4.0",
"react-native": "0.61.5",
"react-native-calendars": "^1.260.0",
"react-native-config": "^0.12.0",
"react-native-easy-grid": "^0.2.2",
"react-native-flash-message": "^0.1.15",
"react-native-gesture-handler": "^1.5.0",
"react-native-modal": "^11.5.2",
"react-native-pell-rich-editor": "^1.0.4",
"react-native-phone-input": "^0.2.4",
"react-native-reanimated": "^1.4.0",
"react-native-render-html": "^4.2.0",
"react-native-render-html-table-bridge": "^0.5.2",
"react-native-safe-area-context": "^0.6.2",
"react-native-safe-area-view": "^1.0.0",
"react-native-screens": "^2.0.0-alpha.8",
"react-native-svg": "^9.13.3",
"react-native-svg-flagkit": "^0.9.5",
"react-native-webview": "^8.0.3",
"react-navigation": "^4.0.10",
"react-navigation-drawer": "^2.3.3",
"react-navigation-hooks": "^1.1.0",
"react-navigation-stack": "^1.10.3",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"redux-devtools-extension": "^2.13.8",
"redux-form": "^8.2.6",
"redux-saga": "^1.1.3",
"styled-components": "^4.4.1"
,
"devDependencies":
"@babel/core": "^7.6.4",
"@babel/runtime": "^7.6.3",
"@react-native-community/eslint-config": "^0.0.5",
"@semantic-release/git": "^7.0.18",
"babel-jest": "^24.9.0",
"babel-plugin-module-resolver": "^3.2.0",
"detox": "^14.6.0",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.5.0",
"eslint-loader": "^3.0.2",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-json": "^2.0.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"fs": "^0.0.1-security",
"jest": "^24.9.0",
"jest-styled-components": "^6.3.4",
"jetifier": "^1.6.4",
"metro-react-native-babel-preset": "^0.57.0",
"opentype.js": "^1.1.0",
"prettier": "^1.18.2",
"react-native-port-patcher": "^1.0.3",
"react-native-version": "^3.2.0",
"react-test-renderer": "^16.11.0",
"semantic-release": "^15.13.30"
,
"jest":
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!react-native|native-base-shoutem-theme|react-navigation|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
],
"moduleNameMapper":
"styled-components": "<rootDir>/node_modules/styled-components/native/dist/styled-components.native.cjs.js"
,
"detox":
"configurations":
"ios.sim.debug":
"binaryPath": "ios/build/BookingLayer/Build/Products/Debug-iphonesimulator/BookingLayer.app",
"build": "xcodebuild -workspace ios/BookingLayer.xcworkspace -scheme BookingLayer -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build/BookingLayer",
"type": "ios.simulator",
"device":
"type": "iPhone 11 Pro"
,
"test-runner": "jest"
知道我能做什么吗?提前非常感谢您!
【问题讨论】:
也许你可以看看这个:github.com/facebook/SoLoader 【参考方案1】:将configurations.all section
添加到android/build.gradle
文件。
这为我解决了这个问题。不要忘记在 android 文件夹中运行 ./gradlew clean。
allprojects
repositories
mavenLocal()
maven
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
maven
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
// add below code - start
configurations.all
resolutionStrategy
// use 0.9.0 to fix crash on Android 11
force "com.facebook.soloader:soloader:0.9.0+"
// code - end
google()
jcenter()
maven url 'https://www.jitpack.io'
将以下内容添加到您的 android/app/build.gradle
文件中:
dependencies
....
implementation 'com.facebook.soloader:soloader:0.9.0+'
....
【讨论】:
以上是关于React Native:由于 SoLoader 问题,应用程序在启动时崩溃的主要内容,如果未能解决你的问题,请参考以下文章
React-native 0.65 (targetSdk=30) android build 由于 react-native-reanimated 而失败
由于 gradle 问题,React Native 演示项目失败
由于节流,react-native firebase fetch() 操作无法成功完成
react-native,“abortOnError false”,但由于 lint 错误,android 构建失败