Android studio 配置Javacv出现“More than one file was found with OS independent path”的解决办法

前言

最近在学习多媒体处理这一块,然后就找到javacv这个开源库,封装了计算机视觉处理所需要的全部库,很强大。

当前配置

  • Windows 10 专业版 64bit
  • Android Studio 3.1.4
  • gradle 3.1.3

##配置
按照开源库中gradle的配置方法。
Android studio 配置Javacv出现“More than one file was found with OS independent path”的解决办法_第1张图片

看着配置就是这么简单,那么就点一下“sync now”,那就进入一段下载时间,下载完之后,点击运行,这里就是为了看配置能不能行。

出现配置问题

诶,果然是不行出现:

	More than one file was found with OS independent path 
	'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-locale-l1-1-0.dll

看着意思是有重复的动态库?

尝试1

嗯,去c盘看看,嗯,找到很多_(:з」∠)_ ,java安装位置下面就有两个,其他应用也有,怎么搞?想一下歪脑筋,删一个试试?
然而并没有什么效果……
那就只能放弃这种偏方了,毕竟也可能影响其他应用。

尝试2

搜索,自己找

  1. 先去开源库Issues看看
    找到了build failed,开心(〃‘▽’〃)还是有好几个人遇到同样的问题,然而,找到正面回答这个问题的答案,但是看起来问题有点类似。
    Android studio 配置Javacv出现“More than one file was found with OS independent path”的解决办法_第2张图片
  2. 尝试
    既然是是找到重复的,那就只取其中一个就好了, 思路OK,试试。
    加一个。
android {
	packagingOptions {
	    pickFirst  'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-locale-l1-1-0.dll'
	    }
    }

构建一下试试。
确实没有相同的错误,但是⊙︿⊙有提示其他文件了,同样是window的动态库,经过若干次的构建,添加pickFirst,最终可以了 -(゜-゜)つロ乾杯~。
3. 结果
增加比较多的pickFirst,是我电脑装了一些其他软件(´・_・`)??还找不到原因。

packagingOptions {
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-locale-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/concrt140.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-utility-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-math-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-locale-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/linux-x86_64/libgomp.so.1'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-stdio-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-convert-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/macosx-x86_64/libusb-1.0.0.dylib'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-time-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/linux-x86/libgomp.so.1'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-math-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-environment-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-multibyte-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-runtime-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/msvcp140.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-stdio-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-string-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/vcruntime140.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-multibyte-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-filesystem-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-time-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/msvcp140.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-environment-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/concrt140.dll'
        pickFirst 'org/bytedeco/javacpp/api-ms-win-crt-heap-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-heap-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-heap-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/vcruntime140.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-convert-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-string-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-runtime-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86/api-ms-win-crt-filesystem-l1-1-0.dll'
        pickFirst 'org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-utility-l1-1-0.dll'

    }

尝试3

  1. 看到android studio的event log有警告信息。
    Android studio 配置Javacv出现“More than one file was found with OS independent path”的解决办法_第3张图片
    提示了当前android studio使用的jdk是android studio自带的,gradle 使用的则是安装的jdk。

  2. 修改android studio 使用的jdk,问题还是没解决 Android studio 配置Javacv出现“More than one file was found with OS independent path”的解决办法_第4张图片

尝试4

  1. 寻找到javacv的使用例子,看到他们使用的依赖并不一样
implementation group: 'org.bytedeco', name: 'javacv', version: '1.4.2'
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: 'android-arm'
//implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.2.0-1.3', classifier: 'android-x86'
implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '4.0.2-1.4.3', classifier: 'android-arm'
//implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.2.1-1.3', classifier: 'android-x86'
  1. 使用这个依赖就不会提示“More than one file was found with OS independent path ‘xxx.dll’”的问题,接口方法也是一样,可以正常使用

结语

这里也就是刚开始配置javacv,具体的时候还没开始,也不知道这能不能用。
多点尝试,搜索还是可以找到差不多的解决办法,一开始不懂,慢慢搞多几次就懂了。

你可能感兴趣的:(Android,javacv)