* What went wrong:
Execution failed for task ':app:transformNativeLibsWithStripDebugSymbolForDebug'.
> A problem occurred starting process 'command 'D:\Users\sky\AppData\Local\Android\Sdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip''
Error:com.android.builder.merge.DuplicateRelativeFileException:
More than one file was found with OS independent path 'META-INF/DEPENDENCIES'
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForRelease'.
> More than one file was found with OS independent path 'lib/armeabi/libJniTest.so'
類似于這種編譯打包時(shí),找不到工具鏈的。由于NDK開發(fā)工具的包的問題導(dǎo)致如果不需要對應(yīng)的架構(gòu)可以直接設(shè)置
packagingOptions {
doNotStrip '*/mips/*.so'
doNotStrip '*/mips64/*.so'
doNotStrip '*/x86_64/*.so'
}
這樣就剔除了mips,mips64,x86_64架構(gòu),也就用不到對應(yīng)的架構(gòu)的工具鏈了。問題自然而解,如果必須要對應(yīng)的架構(gòu)那就下載完整的NDK開發(fā)工具包。
當(dāng)然想打包時(shí)文件重復(fù)的問題也可以使用這個(gè)選項(xiàng),常見的就是引入的so庫重
- exclude 在打包時(shí)移除項(xiàng)目中的相關(guān)文件,不打入apk文件中
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/services/javax.annotation.processing.Processor'exclude 'META-INF/rxjava.properties'
}
- pickFirst 當(dāng)有多個(gè)匹配項(xiàng)的時(shí)候匹配到第一個(gè)就可以了
packagingOptions {
pickFirst "lib/armeabi-v7a/libavdevice.so"
pickFirst "lib/armeabi-v7a/libavcodec.so"
pickFirst "lib/armeabi-v7a/libavfilter.so"
pickFirst "lib/armeabi-v7a/libavformat.so"
pickFirst "lib/armeabi-v7a/libavutil.so"
pickFirst "lib/armeabi-v7a/libswresample.so"
pickFirst "lib/armeabi-v7a/libswscale.so"
pickFirst "lib/armeabi-v7a/libpostproc.so"
}