【发布时间】:2020-04-23 12:39:12
【问题描述】:
我有一个 react native 的项目,我创建了一个包并尝试使用 android 打开,但我收到下一个错误
2020-01-05 16:09:09.460 12947-13005/com.note.principal E/SoLoader: 找不到要加载的 DSO:libhermes.so 2020-01-05 16:09:09.486 12947-13005/com.note.principal E/AndroidRuntime:致命例外: create_react_context 进程:com.note.principal,PID:12947 java.lang.UnsatisfiedLinkError:找不到要加载的 DSO:libhermes.so 在 com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738) 在 com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591) 在 com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529) 在 com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484) 在 com.facebook.hermes.reactexecutor.HermesExecutor.(HermesExecutor.java:20) 在 com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27) 在 com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:952) 在 java.lang.Thread.run(Thread.java:764)
react native 的项目版本是
{
"name": "Notes",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"bundle_android": "react-native bundle --entry-file index.js --platform android --dev false --bundle-output ./index.android.bundle",
"bundle_ios": "react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ./main.jsbundle",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.5",
"react-navigation": "^4.0.10"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/runtime": "^7.7.7",
"@react-native-community/eslint-config": "^0.0.6",
"babel-jest": "^24.9.0",
"eslint": "^6.8.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.57.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
我运行下一个脚本
npm run bundle_android
但是当我运行应用程序时,它总是显示错误
couldn't find DSO to load: libhermes.so 2020-01-05 16:09:09.486
kotling 的代码是
package com.note
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import androidx.appcompat.app.AppCompatActivity
import com.facebook.react.ReactInstanceManager
import com.facebook.react.ReactRootView
import com.facebook.react.common.LifecycleState
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
import com.facebook.react.shell.MainReactPackage
import com.facebook.soloader.SoLoader
import com.note.sdkcore.SDKCorePackage
class ReactActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
private val OVERLAY_PERMISSION_REQ_CODE = 1
private lateinit var mReactRootView: ReactRootView
private lateinit var mReactInstanceManager: ReactInstanceManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
SoLoader.init(this, false)
mReactRootView = ReactRootView(this)
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(application)
.setCurrentActivity(this)
.setApplication(application)
.setBundleAssetName("index.android.bundle")
.addPackage(MainReactPackage())
.addPackage(SDKCorePackage())
.setInitialLifecycleState(LifecycleState.RESUMED)
.build()
// The string here (e.g. "MyReactNativeApp") has to match
// the string in AppRegistry.registerComponent() in index.js
mReactRootView.startReactApplication(mReactInstanceManager, "Notes", null)
setContentView(mReactRootView)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
val intent = Intent(
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:$packageName")
)
startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE)
}
}
}
override fun invokeDefaultOnBackPressed() {
super.onBackPressed()
}
override fun onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed()
} else {
super.onBackPressed()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
// SYSTEM_ALERT_WINDOW permission not granted
}
}
}
mReactInstanceManager?.onActivityResult(this,requestCode, resultCode, data)
}
}
有人知道解决办法
【问题讨论】:
-
我在用 android 打开捆绑包时遇到问题,我正在搜索不同的信息,但这是我唯一能正常工作的东西。然后是用户要打开捆绑包时要解决的步骤。我更改了描述并指定了技术
标签: javascript android maven react-native gradle