INSTALL_FAILED_MISSING_SHARED_LIBRARY 导致应用无法安装

huangapple go评论83阅读模式
英文:

INSTALL_FAILED_MISSING_SHARED_LIBRARY Causes app to not install

问题

我遇到了错误:

找到了多个具有独立于操作系统路径的文件 'lib/x86_64/libopencv_java3.so'。如果您正在使用 jniLibs 和 CMake IMPORTED 目标,请参阅 https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake 上的内容。

链接将我带到一个 Android 4.2 的发行说明页面,所以与我的问题无关。

我正在使用一个基于 OpenCV 构建的 DocumentScanner 库,该库使用 jnilibs,并且我遇到了与该 jnilibs 相关的问题。

因此,

我查阅了 Android 开发指南,并找到了以下内容:

CMake 使用的预构建依赖的自动打包
Android Gradle 插件的早期版本要求您通过使用 jniLibs 显式地打包您的 CMake 外部本机构建使用的任何预构建库,您可能在模块的 src/main/jniLibs 目录中拥有库,或者可能在构建.gradle 文件中配置的其他某个目录中:

    sourceSets {
        main {
            // libs 目录包含了由 CMakeLists.txt 中的 IMPORTED 目标通过 jniLibs 使用的预构建库。
            jniLibs.srcDirs = ['libs']
        }
    }

在 Android Gradle 插件 4.0 中,上述配置不再必要,并将导致构建失败:

* 发生了什么:
执行任务 ':app:mergeDebugNativeLibs' 失败。
> 在执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 时出错
> 找到了多个具有独立于操作系统路径 'lib/x86/libprebuilt.so' 的文件。

外部本机构建现在会自动打包这些库,因此使用 jniLibs 显式打包库会导致重复。为避免构建错误,请将预构建库移动到 jniLibs 之外的位置,或从 build.gradle 文件中删除 jniLibs 配置。

因此,现在在遵循上述操作后,即移动库/从 gradle.build 中删除库等操作后,应用程序会构建并开始安装,但随后我遇到了错误:

安装未成功。
无法安装该应用程序:INSTALL_FAILED_MISSING_SHARED_LIBRARY。

帮助将不胜感激。

英文:

I was getting the error

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

the link takes me to a page with a release notes for android 4.2, so there is nothing pretaining to my problem,

I am using a Documentscanner library buitl with opencv and that uses jnilibs and the problem I have is with that jnilibs

so

I looked through the Android Dev Guide and came across this

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.

So now after following the above IE Moving the library/ removing from my gradle.build etc.
The app builds and starts to install but then I get the error

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

Help would be appreciated

答案1

得分: 0

请按照这个答案操作。

> 根据
> https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs
>
> 如果您正在使用 Android Gradle 插件 4.0,请将任何被 IMPORTED CMake 目标使用的库移出您的 jniLibs 目录以避免这个错误。
>
> 所以您只需要将 ${ANDROID_ABI}/libdlib.so 文件夹移动到
> 另一个位置,比如创建一个名为 cmakeLibs 的新目录
>
> 例如:
>
> set_target_properties( dlib
> PROPERTIES IMPORTED_LOCATION
> ${CMAKE_SOURCE_DIR}/../cmakeLibs/${ANDROID_ABI}/libdlib.so )

INSTALL_FAILED_MISSING_SHARED_LIBRARY 导致应用无法安装

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

英文:

Please follow this answer.

> According to
> https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs
>
> If you are using Android Gradle Plugin 4.0, move any libraries that
> are used by IMPORTED CMake targets out of your jniLibs directory to
> avoid this error.
>
> So you only need to move the ${ANDROID_ABI}/libdlib.so folder to
> another place such as creating a new directory name cmakeLibs
>
> eg:
>
> set_target_properties( dlib
> PROPERTIES IMPORTED_LOCATION
> ${CMAKE_SOURCE_DIR}/../cmakeLibs/${ANDROID_ABI}/libdlib.so )

INSTALL_FAILED_MISSING_SHARED_LIBRARY 导致应用无法安装

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

答案2

得分: 0

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

如果你遇到相同的错误(或者我建议你如果你遇到OpenCV的问题)

这是我解决的方式:

  1. 移除所有与错误相关的库和模块(例如OpenCV等)。

  2. 然后下载OpenCV Android模块并导入它。

  3. 接着导入使用OpenCV的库(在我的情况下是GitHub上的AndroidScannerDemo,由jhansireddy创建)。

  4. 最后,调整你的代码以使用你正在使用的库。

英文:

I have solved this by importing the latest opencv module manually, the problem was that the opencv included in the library I was using was outdated.

if you get the same error(or I would recomend doing this if you having issues with opencv)

This is how i fixed

Removed all the libraries and modules pertaining to the error(Opencv etc)

Then download openCV android module and import it

then import the library that uses openCV (In my case it was
AndroidScannerDemo by jhansireddy on github)

and then lastly Adjust your code to use the library you are using

huangapple
  • 本文由 发表于 2020年10月15日 20:09:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/64371288.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定