pra*_*rya 12 android react-native
我的反应本机应用程序运行正常,但突然我开始收到错误:
错误1:Execution failed for task ':react-native-webview:compileDebugKotlin'.
因此,我在 android/build.gradle 中添加了此内容kotlinVersion = "1.5.31",并且还添加了依赖项classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"。
之后我收到以下错误:
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'lib/arm64-v8a/libfbjni.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake
Run Code Online (Sandbox Code Playgroud)
为此,在 android{...} 下的 android/app/build.gradle 内我添加了:
packagingOptions {
pickFirst 'lib/x86/libc++_shared.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/libfbjni.so'
}
Run Code Online (Sandbox Code Playgroud)
但即使在此之后我再次遇到同样的错误:More than one file was found with OS independent path 'lib/arm64-v8a/libfbjni.so'
Ali*_*san 14
在android>build.gradle文件中添加以下行-
allprojects {
repositories {
...
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
该问题发生于2022年11月4日。参见参考资料:https ://github.com/facebook/react-native/issues/35210
您可以在 中添加给定的代码app/build.gradle。我通过添加以下代码解决了我的错误。
android {
defaultConfig {
}
packagingOptions {
pickFirst '**/libjsc.so'
pickFirst '**/libc++_shared.so'
pickFirst '**/libfbjni.so'
pickFirst '**/llibturbomodulejsijni.so'
pickFirst '**/libturbomodulejsijni.so'
// Add more according to your error here
}
}
Run Code Online (Sandbox Code Playgroud)
添加后,pickFirst '**/libfbjni.so'我又遇到了两个错误,因此我添加了pickFirst '**/llibturbomodulejsijni.so'并pickFirst '**/libturbomodulejsijni.so'解决了我的错误。
如果您的应用程序在打开时崩溃,请android/build.gradle添加此内容
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 0
基于 @BK52 提到的 github 线程,我将此片段添加到app/build.gradle
android {
defaultConfig {
// existing code
packagingOptions {
pickFirst '**/libc++_shared.so'
pickFirst '**/libfbjni.so'
}
}
}
Run Code Online (Sandbox Code Playgroud)
它对我有用,并且错误似乎消失了。我使用的是 RN 0.68.2。
| 归档时间: |
|
| 查看次数: |
13801 次 |
| 最近记录: |