-
Notifications
You must be signed in to change notification settings - Fork 11
Description
首页可以正常载入,但是无论点击同步加载和异步加载都会闪退;我在adb中捕获了相应错误信息:
首先是同步加载的错误:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libreact_featureflagsjni.so" not found
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:998)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1661)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:24)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:52)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:812)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsCxxInterop.(ReactNativeFeatureFlagsCxxInterop.kt:28)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsCxxAccessor.enableBridgelessArchitecture(ReactNativeFeatureFlagsCxxAccessor.kt:117)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.enableBridgelessArchitecture(ReactNativeFeatureFlags.kt:65)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.lambda$onCreate$0(ReactActivityDelegate.java:126)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.$r8$lambda$HPdXfLmAU1y4Wc1XbwAHziPP2WA(Unknown Source:0)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.systrace.Systrace.traceSection(Systrace.kt:39)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:117)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:47)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.awesomeproject.sync.BaseContainerReactActivity.onCreate(BaseContainerReactActivity.java:29)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8422)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8395)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1403)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3845)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4014)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:111)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:240)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.os.Looper.loop(Looper.java:351)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8423)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
03-13 19:31:16.331 9498 9498 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
其次是异步加载的错误:
03-13 19:31:18.823 9756 9756 E AndroidRuntime: java.lang.AssertionError
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.facebook.infer.annotation.Assertions.assertNotNull(Assertions.java:31)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.facebook.react.ReactInstanceManager$ReactContextInitParams.(ReactInstanceManager.java:211)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.recreateReactContextInBackground(ReactInstanceManager.java:1185)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader(ReactInstanceManager.java:531)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.recreateReactContextInBackgroundInner(ReactInstanceManager.java:523)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.createReactContextInBackground(ReactInstanceManager.java:458)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.awesomeproject.async.AsyncLoadActivityDelegate.initReactContextInBackground(AsyncLoadActivityDelegate.java:86)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.awesomeproject.async.AsyncLoadManager.prepareReactNativeEnv(AsyncLoadManager.java:47)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.awesomeproject.async.AsyncLoadGuideActivity.onStart(AsyncLoadGuideActivity.java:29)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1529)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.Activity.performStart(Activity.java:8447)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3897)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:240)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.os.Looper.loop(Looper.java:351)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8423)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
03-13 19:31:18.823 9756 9756 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
我用的"react": "19.0.0","react-native": "0.78.0",java17
gradle相关配置:
buildscript {
ext {
buildToolsVersion = "35.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "27.1.12297006"
kotlinVersion = "2.0.21"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
apply plugin: "com.facebook.react.rootproject"
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
/**
-
This is the configuration block to customize your React Native Android app.
-
By default you don't need to apply any configuration, just uncomment the lines you need.
/
react {
/ Folders */
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
// cliFile = file("../../node_modules/react-native/cli.js")/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]/* Autolinking */
autolinkLibrariesWithApp()
}
/**
- Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
/**
- The preferred build flavor of JavaScriptCore (JSC)
- For example, to use the international variant, you can use:
def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+
- The international variant includes ICU i18n library and necessary data
- allowing to use e.g.
Date.toLocaleString
andString.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 = 'io.github.react-native-community:jsc-android:2026004.+'
def enableSeparateBuildPerCPUArchitecture = false
android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
namespace "com.awesomeproject"
defaultConfig {
applicationId "com.awesomeproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a" // , "arm64-v8a", "x86_64" , "x86"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
相关AndroidManifest.xml配置:
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
android:supportsRtl="true">
<activity android:name=".async.AsyncLoadGuideActivity"></activity>
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity android:name=".sync.SyncLoadContainerReactActivity"
android:exported="true"/>
<activity android:name=".async.AsyncLoadContainerReactActivity"
android:exported="true" />
</application>
如果作者有兴趣看一看这个问题,我可以将项目发送至您的邮箱,感激不尽