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

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

问题描述

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

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

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

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

但是在将libarcore.so文件放在jniLib

我遇到了这样的错误

使用操作系统独立路径'lib/armeabi-v7a/libarcore_sdk_jni.so'找到多个文件

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'
}

然后这个

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'
}

还有这个 包装选项{ 排除'lib/arm64-v8a/libarcore_sdk_jni.so' 排除'lib/armeabi-v7a/libarcore_sdk_jni.so' 排除'lib/x86/libarcore_sdk_jni.so' 排除'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' }

没有任何帮助.

据我所知,问题是-我在jniLibs目录下有一个arcore.so文件的副本,在这里Build之后创建了一个副本

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文件,并且从源代码构建(或以其他方式引用).

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

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

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.

通常,人们可以在 build.gradle :

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)
    }
}

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

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天全站免登陆