在操作系统独立路径“lib/armeabi-v7a/libarcore_sdk_jni.so"中找到了多个文件 [英] More than one file was found with OS independent path 'lib/armeabi-v7a/libarcore_sdk_jni.so'

查看:25
本文介绍了在操作系统独立路径“lib/armeabi-v7a/libarcore_sdk_jni.so"中找到了多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在 SO 上有一些类似的问题,但它对我不起作用...

我创建了使用 ArCore 的 Android 库.这是一个关于 SO 如何不包含 .so 文件的问题,如果我使用创建的 ndk lib?还有一个答案听起来很对

我遇到了这样的错误

<块引用>

发现多个文件的操作系统独立路径为lib/armeabi-v7a/libarcore_sdk_jni.so"

所以,我试图以这种方式修复它

那么,如何解决它?

解决方案

您可能已经添加了共享的 .so 文件从源代码构建(或以其他方式引用它们)).

两者不能同时进行,因此您要么需要从 source 并删除那些 .so 文件 - 或者删除 arcore-android-sdk 模块并保留 .so 文件.Java dependencies 也可能会引入本地程序集,而 build.gradle 的那部分丢失了(只需浏览外部库"中的 AR 核心以查看它包含的内容,如果它存在于那里).使用预先构建的库通常可以更快地构建并节省时间 - 建议这样做,除非需要编辑 cpp 源.

通常可以在此 build.gradle:

依赖项{实现com.google.ar:core:1.13.0"本地人com.google.ar:core:1.13.0"}//从 natives 配置中的 aars 中提取共享库.//这样做是为了让 NDK 构建可以访问这些库.任务extractNativeLibraries() {//始终提取,这可确保在版本更改时更新本机库.output.upToDateWhen { false }先做{configuration.natives.files.each { f ->复制 {来自 zipTree(f)进入arcore_libpath包括jni/**/*"}}}}任务.whenTaskAdded {任务->if (task.name.contains("external") && !task.name.contains("Clean")) {task.dependsOn(extractNativeLibraries)}}

如果配置不正确,此类 Gradle 任务也可能是重复的原因.packagingOptions 在任何情况下都是错误的方法,因为链接器已经不知道要链接哪个.

I know there is a few similar questions on SO, but it does not work for me...

I created Android lib, that use ArCore. It was a question on SO how to don't include .so file if I use created ndk lib? There is also one answer that sounds right

https://stackoverflow.com/a/58963852/5709159

But after I putted libarcore.so files under my jniLib

I got such error

More than one file was found with OS independent path 'lib/armeabi-v7a/libarcore_sdk_jni.so'

So, I tried to fix it this ways

https://stackoverflow.com/a/44962630/5709159

sourceSets.main {
        jniLibs.srcDir 'src/main/jniLibs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }

https://stackoverflow.com/a/56453718/5709159

packagingOptions {
    pickFirst 'src/main/jniLibs/arm64-v8a/libarcore_sdk_jni.so'
    pickFirst 'src/main/jniLibs/armeabi-v7a/libarcore_sdk_jni.so'
    pickFirst 'src/main/jniLibs/x86/libarcore_sdk_jni.so'
    pickFirst 'src/main/jniLibs/x86_64/libarcore_sdk_jni.so'
}

then this

packagingOptions {
    pickFirst 'lib/arm64-v8a/libarcore_sdk_jni.so'
    pickFirst 'lib/armeabi-v7a/libarcore_sdk_jni.so'
    pickFirst 'lib/x86/libarcore_sdk_jni.so'
    pickFirst 'lib/x86_64/libarcore_sdk_jni.so'
}

and also this packagingOptions { exclude 'lib/arm64-v8a/libarcore_sdk_jni.so' exclude 'lib/armeabi-v7a/libarcore_sdk_jni.so' exclude 'lib/x86/libarcore_sdk_jni.so' exclude 'lib/x86_64/libarcore_sdk_jni.so' }

Nothing helped.

As far as I understand issue is - I have one copy of arcore.so files under my jniLibs dir and one copy created after Build here

So, how to fix it?

解决方案

You've likely added the shared .so files and build from source (or reference them otherwise).

One cannot do both at the same time, so you'd either need to build from source and delete those .so files - or delete the arcore-android-sdk module and keep the .so files. Java dependencies might also pull in native assembly, while that part of the build.gradle is missing (just browse AR core in the "External Libraries" to see what it contains, in case it exists there). Using pre-built libraries generally builds quicker and saves time - which is suggested, unless needing to edit cpp sources.

Usually one can provide the dependencies alike in this build.gradle:

dependencies {
    implementation "com.google.ar:core:1.13.0"
    natives "com.google.ar:core:1.13.0"
}

// Extracts the shared libraries from aars in the natives configuration.
// This is done so that NDK builds can access these libraries.
task extractNativeLibraries() {
    // Always extract, this ensures the native libs are updated if the version changes.
    outputs.upToDateWhen { false }
    doFirst {
        configurations.natives.files.each { f ->
            copy {
                from zipTree(f)
                into arcore_libpath
                include "jni/**/*"
            }
        }
    }
}

tasks.whenTaskAdded {
    task-> if (task.name.contains("external") && !task.name.contains("Clean")) {
        task.dependsOn(extractNativeLibraries)
    }
}

Such Gradle task could also be the reason for the duplicates, when it's not configured properly. packagingOptions are in every case the wrong approach, when the linker already doesn't know which one to link.

这篇关于在操作系统独立路径“lib/armeabi-v7a/libarcore_sdk_jni.so"中找到了多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆