【问题标题】:INSTALL_FAILED_MISSING_SHARED_LIBRARY Causes app to not installINSTALL_FAILED_MISSING_SHARED_LIBRARY 导致应用无法安装
【发布时间】:2020-10-15 12:09:51
【问题描述】:

我遇到了错误

More than one file was found with OS independent path 'lib/x86_64/libopencv_java3.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

该链接将我带到一个带有 android 4.2 发行说明的页面,因此没有任何问题可以解决我的问题,

我正在使用带有 opencv 并使用 jnilibs 的 Documentscanner 库 buitl,而我遇到的问题是那个 jnilibs

所以

我浏览了 Android 开发指南并遇到了这个

Automatic packaging of prebuilt dependencies used by CMake
Prior versions of the Android Gradle Plugin required that you explicitly package any prebuilt libraries used by your CMake external native build by using jniLibs. You may have libraries in the src/main/jniLibs directory of your module, or possibly in some other directory configured in your build.gradle file:

    sourceSets {
        main {
            // The libs directory contains prebuilt libraries that are used by the
            // app's library defined in CMakeLists.txt via an IMPORTED target.
            jniLibs.srcDirs = ['libs']
        }
    }

With Android Gradle Plugin 4.0, the above configuration is no longer necessary and will result in a build failure:

* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'lib/x86/libprebuilt.so'

External native build now automatically packages those libraries, so explicitly packaging the library with jniLibs results in a duplicate. To avoid the build error, move the prebuilt library to a location outside jniLibs or remove the jniLibs configuration from your build.gradle file.

所以现在按照上面的 IE 移动库/从我的 gradle.build 等中删除。 该应用程序构建并开始安装,但随后出现错误

Installation did not succeed.
The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY

我们将不胜感激

【问题讨论】:

  • 您能否向我们展示完整的 build.gradle 文件并解释您是如何包含和/或构建该库的?如果您下载了东西,还链接到您下载的内容。如果可用,还向我们展示 CMakeLists.txt
  • 与 build.gradle 一起显示 find 输出或项目的目录结构
  • 你可能会觉得这个话题很有趣:stackoverflow.com/questions/62088079/…

标签: java android cmake


【解决方案1】:

请关注this answer

根据 https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs

如果您使用的是 Android Gradle 插件 4.0,请移动任何库 由 jniLibs 目录中的 IMPORTED CMake 目标使用 避免这个错误。

所以你只需要将 ${ANDROID_ABI}/libdlib.so 文件夹移动到 另一个地方比如新建一个目录名cmakeLibs

例如:

set_target_properties( dlib
    PROPERTIES IMPORTED_LOCATION
    ${CMAKE_SOURCE_DIR}/../cmakeLibs/${ANDROID_ABI}/libdlib.so )

参考 - https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs

【讨论】:

  • 感谢您的帮助,但解决方案真的很简单,忘记更新问题,我只需要导入最新的 opencv 模块并修复错误
【解决方案2】:

我通过手动导入最新的opencv模块解决了这个问题,问题是我使用的库中包含的opencv已经过时了。

如果您遇到相同的错误(或者如果您遇到 opencv 问题,我建议您这样做)

我就是这样解决的

删除了与错误相关的所有库和模块(Opencv 等)

然后下载openCV android模块并导入

然后导入使用 openCV 的库(在我的例子中是 AndroidScannerDemo by jhansireddy on github)

然后最后调整您的代码以使用您正在使用的库

【讨论】:

    猜你喜欢
    • 2012-03-14
    • 1970-01-01
    • 2012-01-27
    • 2014-05-18
    • 2018-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-11
    相关资源
    最近更新 更多