React Native Basic应用程序在谷歌nexus 5s和Redmi K20上崩溃



我创建了一个基本的react应用程序。在redmi k20上使用它作为物理应用程序,使用usb调试以及在模拟器上使用nexus5s,它崩溃了,没有显示任何错误

app.js

import React from 'react';
import {
Text,
View
} from 'react-native';

const App = () => {
return (
<View>
<Text>Ross Wala Haiii;</Text>
</View>
);
};

export default App;

app/build.gradle

apply plugin: "com.android.application"
import com.android.build.OutputFile

project.ext.react = [
enableHermes: false,  // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"

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.storiesapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"

}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false  // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
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"
}
}
// 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"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"  // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
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)

android/build.gradle

buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
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")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}

它显示:

java.lang.Unsatisfiedlinkerror: couldn't find DSO to load:
libfbjni.so result: 0
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:825) e(SoLoader.java:825) at
com.facebook.soloader.SoLoader.loadLibraryBySoName(S oLoader.java:673) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.jav a:611) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.jav a:559) at
com.facebook.soloader.NativeLoaderToSoLoader Delegate.
loadLibrary(NativeLoaderToSoLoaderDelegate.java:25) at com.facebook.soloader.nativeloader. NativeLoader.loadLibr ary(NativeLoader.java:44) at com.facebook.jni.HybridData.<clinit>(HybridData.java:
34) at com.facebook.flipper.android. Flippers Thread.run(Flipper The ead.java:25)

我使用RN 16.13.1在windows 10 上

这是我第一次接触母语,可能缺乏基本的母语知识请帮助

我相信这与github上打开的问题非常相似。您可能需要订阅该线程,以便将来更新有关修复SoLoader问题的信息。

为了解决这个问题,其中一个开发人员在android/app/build.gradle:下添加了以下内容

dependencies {
implementation 'com.facebook.soloader:soloader:0.9.0+'
...
}

至于我,由于我的其他依赖关系依赖于SoLoader,我在android/app/build.gradle下的声明依赖关系上添加了以下内容:

configurations.all {
resolutionStrategy {
force "com.facebook.soloader:soloader:0.8.2"
}
}
dependencies {
...
}

我的应用程序现在在Nexus 5s模拟器上运行良好,没有SoLoader问题。

最新更新