就像标题所说的一样。
当我启动我的Android应用程序时,出现以下错误
No implementation found for void io.objectbox.BoxStore.nativeDelete(long)
我急于添加一点完整的build.gradle和应用程序代码,但是我认为我应该发布,以防万一有一个已知且显而易见的解决方案。
我已经尝试过1.1.0和1.2.0
更新:
一些进一步的信息。我正在尝试在我的LibGDX项目中使用ObjectBox。 LibGDX是一个跨平台游戏库,您可以用Java编写代码,并吐出Android,iOS和桌面版本。
我决定不尝试使用ObjectBox的Android实现,而是尝试使用Java版本,以便理论上可以在所有三个平台上使用它。我不确定,但这也许是问题所在。使用Java版本,但在Android平台上。
更新2:(Stacktrace)
11-10 09:48:05.159 16269-16278/com.myapp E/System: java.lang.UnsatisfiedLinkError: No implementation found for void io.objectbox.BoxStore.nativeDelete(long) (tried Java_io_objectbox_BoxStore_nativeDelete and Java_io_objectbox_BoxStore_nativeDelete__J)
at io.objectbox.BoxStore.nativeDelete(Native Method)
at io.objectbox.BoxStore.close(BoxStore.java:355)
at io.objectbox.BoxStore.finalize(BoxStore.java:245)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)
at java.lang.Thread.run(Thread.java:762)
11-10 09:48:05.261 16269-16269/com.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 16269
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-1/lib/arm64, /data/app/com.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libobjectbox.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:972)
at java.lang.System.loadLibrary(System.java:1567)
at io.objectbox.internal.NativeLibraryLoader.<clinit>(NativeLibraryLoader.java:44)
at io.objectbox.internal.NativeLibraryLoader.ensureLoaded(NativeLibraryLoader.java:82)
at io.objectbox.BoxStore.<init>(BoxStore.java:170)
at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:243)
at com.myapp.db.DB.createMyObjectBox(DB.java:28)
at com.myapp.db.DB.updateAchievements(DB.java:35)
at com.myapp.screens.MainMenuScreen.achievementsFinishedLoading(MainMenuScreen.java:1241)
at com.myapp.android.AndroidPlayServices$GetAchievementsAsyncTask.onPostExecute(AndroidPlayServices.java:418)
at com.myapp.android.AndroidPlayServices$GetAchievementsAsyncTask.onPostExecute(AndroidPlayServices.java:364)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
1
build.gradle(很多可能被忽略,但这是我在其中使用ObjectBox的“核心”项目,而不是Android。东西和Windows东西,只需使用linux扩展/ lib)
buildscript {
ext.objectboxVersion = '1.1.0'
// ext {
// osName = System.getProperty("os.name").toLowerCase()
// isLinux = osName.contains("linux")
// isWindows = osName.contains("windows")
// is64 = System.getProperty("sun.arch.data.model") == "64"
// isLinux64 = isLinux && is64
// isWindows64 = isWindows && is64
// }
repositories {
mavenCentral()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://maven.fabric.io/public' }
maven { url "https://maven.java.net/content/groups/public/" }
maven { url "http://objectbox.net/beta-repo/" }
maven { url "https://plugins.gradle.org/m2/" }
google()
}
// https://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml look here for up to date fabric version
dependencies {
classpath 'com.github.triplet.gradle:play-publisher:1.1.5'
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'io.fabric.tools:gradle:1.24.4'
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.12"
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "Masters Gallery by Reiner Knizia"
gdxVersion = '1.9.6'
roboVMVersion = '1.12.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.6.0'
aiVersion = '1.6.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "http://objectbox.net/beta-repo/" }
google()
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.github.triplet.play'
// apply plugin: 'io.objectbox' // after applying Android plugin
repositories {
jcenter()
// maven { url 'https://maven.fabric.io/public' }
flatDir { dirs 'libs' }
}
// .aar repositories
repositories {
flatDir { dirs 'libs' }
}
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
compile 'com.android.support:support-annotations:27.0.0'
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'com.google.android.gms:play-services-games:11.6.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.sun.mail:android-mail:1.6.0'
compile 'com.sun.mail:android-activation:1.6.0'
}
}
project(":core") {
apply plugin: "java"
apply plugin: 'net.ltgt.apt-idea'
apply plugin: 'io.objectbox'
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "io.objectbox:objectbox-java:$objectboxVersion"
// everything compiles without this, but it might still be needed
// if (isLinux64) {
// compile "io.objectbox:objectbox-linux:$objectboxVersion"
// } else if (isWindows64) {
// compile "io.objectbox:objectbox-windows:$objectboxVersion"
// } else println("Native dependency could not be set up for unsupported OS: " + osName)
compile fileTree(dir: 'libs', include: '*.jar')
compile fileTree(dir: 'libs', include: '*.aar')
}
}
使用ObjectBox的数据库类
private void createMyObjectBox() throws IOException {
File tempFile = File.createTempFile("objectstorefile", "");
tempFile.delete();
boxStoreDir = tempFile;
Gdx.app.error("DB","tempfile="+tempFile);
Gdx.app.error("DB","boxstoredir="+boxStoreDir);
store = MyObjectBox.builder().directory(boxStoreDir).build();
}
最佳答案
如果我没记错的话,您只需在Java项目中定义ObjectBox依赖项。似乎缺少的是Android特定的工件:
compile "io.objectbox:objectbox-android:$objectboxVersion"
这包括共享库(本机.so文件)。
其他说明:
确保所有库都对ABI提供一致的支持。看起来您的LibGDX带有armeabi,它非常旧,因此没有包含在ObjectBox中。 Android的ObjectBox具有armeabi-v7a,arm64-v8a和x86支持。我建议从您的LibGDX设置中删除所有其他内容。否则,该应用程序可能会在某些设备上崩溃,因为它无法混合使用32位和64位库。
您可以通过将编译
"io.objectbox:objectbox-linux:$objectboxVersion"
添加到Linux机器的桌面项目中来尝试桌面版ObjectBox。您使用的ObjectBox版本已过时。请检查changelog以获取最新版本。