Caused by: java.lang.UnsatisfiedLinkError: dlopen Failed: cannot locate symbol "__aeabi_memcpy4" referenced by "/data/app/com.app.myapp-1/lib/arm/libJniBitmapOperationsLibrary.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:1076)
at com.jni.bitmap_operations.JniBitmapHolder.<clinit>(JniBitmapHolder.java:11)
<...>
java.lang.UnsatisfiedLinkError: dlopen Failed: empty/missing DT_HASH in "cpplibrary.so" (built with --hash-style=gnu?)
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:526)
我可以在互联网上找到的这个错误提及(例如这个Google Groups post)讨论了构建lib的问题,这会导致每次运行应用程序时都会出现此错误.几乎没有关于为什么偶尔会发生这种情况的信息. This post是我能找到的最接近的.
public class MainActivity extends AppCompatActivity {
static {
System.loadLibrary("myccplib"); // "myjni.dll" in Windows,"libmyjni.so" in Unixes
}
public native String stringFromJNI();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String s = stringFromJNI();
Log.d("stringFromJNI " + s);
}
}
我的CMakeLists.txt文件:
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library,sets it as either STATIC
# or SHARED,and provides the relative paths to its source code.
# You can define multiple libraries,and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp )
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default,you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries,such as libraries you define in this
# build script,prebuilt third-party libraries,or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} )
问题:我崩溃了:
2020-10-14 19:02:45.465 25918-25918/com.example.tof E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tof,PID: 25918
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.tof-t8Csh416BSdO6UBfZv0mOw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.tof-t8Csh416BSdO6UBfZv0mOw==/lib/arm64,/system/lib64,/product/lib64]]] Couldn''t find "libmyccplib.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.example.tof.MainActivity.<clinit>(MainActivity.java:37)
java.lang.UnsatisfiedLinkError: Couldn't find DSO to load: libreactnativejni.so
at com.facebook.soloader.soLoader.loadLibraryBySoName(SoLoader.java:213)
at com.facebook.soloader.soLoader.loadLibrary(SoLoader.java:178)
at com.facebook.react.bridge.JSCJavaScriptExecutor.<clinit>(JSCJavaScriptExecutor.java:19)
at com.facebook.react.ReactInstanceManager.onjsBundleLoadedFromServer(ReactInstanceManager.java:413)
at com.facebook.react.ReactInstanceManager.createReactContextInBackground(ReactInstanceManager.java:236)
React Native on Android doesn’t provide a 64-bit version of the libreactnativejni.so native library, which can cause compatibility issues on 64-bit devices. I ran into this while attempting to integrate React Native with a large existing application I’m developing.
来自Facebook的反应:
“Thanks for reporting! Yes we don’t provide 64-bit version of the native code and the system should always fall back to 32-bit.“
And:
“Most Android projects use a number of 3rd-party libraries, and any that include native 64-bit code will cause React Native to fail.“
以下SO回答Use 32-bit jni libraries on 64-bit android解释了回退到32位库以及您无法混合使用的事实.因此,如果找到64位,则所有都应为64位
我建议阅读Github问题#2814.建议了多个修复程序,但是哪种方法有效取决于您的情况.
发行人还写了一个博客:Mixing 32- and 64-bit Dependencies in Android