【发布时间】:2015-03-24 16:30:38
【问题描述】:
我正在使用两个库的 Android Studio 中制作应用程序。带有 Android 包装器和 jar 库的本机库。 由于某种原因,如果将其他 jar 库编译到项目中,则不会加载本机库。因此,如果我仅使用本机库运行该应用程序,则一切正常。我将另一个 jar-library 添加到我的 gradle-file 并繁荣...... UnsatisfiedLinkError:
java.lang.UnsatisfiedLinkError: Couldn't load MobileOcrEngine from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.app-1, /vendor/lib, /system/lib]]]: findLibrary returned null
当我使用这个时,我的应用程序运行良好:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
}
尝试时出现错误:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
compile files('libs/realm-0.78.0.jar')
}
或者当我尝试使用相同的库但使用 Maven 存储库时:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
compile 'io.realm:realm-android:0.78.0'
}
或者如果我尝试将 jar 放在 jniLibs 文件夹中:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
}
我不知道问题的根源在哪里。使用两个库之一,Android Studio 还是我做错了什么?
注意: 我知道 StackOverflow 上有很多关于 UnsatisfiedLinkErrors 的问题,但这些都没有为我的问题提供解决方案。如果它是我使用的唯一库,我加载本机库没有问题...
【问题讨论】:
标签: android android-studio gradle realm unsatisfiedlinkerror