简体   繁体   English

尝试构建android应用程序捆绑包时出现“使用保留文件或目录名称'lib'”错误

[英]“Uses reserved file or directory name 'lib'” error when trying to build android app bundle

I'm trying to build an app bundle but I'm getting the following error: 我正在尝试构建应用程序捆绑包,但出现以下错误:

File 'root/lib/x86_64-MacOSX-gpp/jni/libjunixsocket-native-2.0.4.jnilib' uses reserved file or directory name 'lib'.

For what I've seen from similar questions, this issue is normally solved juggling dependencies or files in the project structure, but in this case it seems to point to a native library involved in app architecture if i'm not mistaken. 对于我从类似问题中看到的内容,此问题通常可以通过解决项目结构中的依赖项或文件来解决,但在这种情况下,如果我没有记错的话,它似乎指向应用程序体系结构中涉及的本机库。 Any ideas how to solve this? 任何想法如何解决这个问题?

It looks like you are adding a dependency as a jar instead of an aar . 看起来您正在将依赖项添加为jar而不是aar

The aar contains the information of what files should be considered as Android resources, native libraries, etc. in the app. aar包含应在应用程序aar哪些文件视为Android资源,本机库等的信息。 A jar is just a plain list of files without Android concept. jar只是没有Android概念的简单文件列表。 Because the jar you're depending on contains a directory lib , the files would normally end up being considered as native libraries, but because the files come from a jar instead of an aar, the build system warns that it's unlikely to be a native library and may have unintended consequences at runtime. 因为您所依赖的jar包含目录lib ,这些文件通常最终会被视为本机库,但是由于这些文件来自jar而不是aar,因此生成系统会警告它不太可能是本机库可能会在运行时产生意想不到的后果。

Try to package that library as an .aar instead of a .jar . 尝试将该库打包为.aar而不是.jar See this documentation: https://developer.android.com/studio/projects/android-library 请参阅此文档: https : //developer.android.com/studio/projects/android-library

Edit: Note that this file could not be loaded by the Android platform if it was included as is in the APK, so even though the previous build systems would allow you to put anything in an APK, the Android App Bundle is more restrictive to ensure that you don't accidentally put unnecessary files which would increase unnecessarily the size of your app. 编辑:请注意,如果该文件按原样包含在APK中,则无法由Android平台加载,因此,即使先前的构建系统允许您将任何内容放入APK中,Android App Bundle的限制也要严格得多,以确保您不会意外地放入不必要的文件,而不必要的文件会不必要地增加应用程序的大小。

Ok it is working now! 好的,现在可以工作了! Steps I used to found the problem (thanks for pointing me in the right direction @Pierre) 我曾经发现问题的步骤(感谢@Pierre向我指出正确的方向)

Run a gradle build --scan from your terminal or go to the Gradle tab in Android Studio, select :app, help , androidDependencies to see your dependency graph. 从您的终端运行gradle build --scan或转到Android Studio中的Gradle选项卡,选择:app,help和androidDependencies以查看您的依赖关系图。

Search the dependency graph for the library name related to the problem ( in my case I searched for socket, there was no match for libjunixsocket for example). 在依赖关系图中搜索与问题相关的库名(在我的情况下,我搜索套接字,例如,与libjunixsocket不匹配)。

Going upwards on the dependency tree I realized it was caused by the 'io.voucherify.android.client:voucherify-android-sdk:2.1.0' dependency. 在依赖关系树上往上走,我意识到它是由“ io.voucherify.android.client:voucherify-android-sdk:2.1.0”依赖关系引起的。

I just added @aar at the end of the dependency implementation, and I managed to build the app bundle. 我只是在依赖项实现的末尾添加了@aar,并设法构建了应用程序捆绑包。

implementation 'io.voucherify.android.client:voucherify-android-sdk:2.1.0@aar'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 构建Android Bundle的问题-引发错误“文件'root / lib / commons-io-2.4.jar'使用保留的文件或目录名称'lib'” - Issue with building Android Bundle - throws error “File 'root/lib/commons-io-2.4.jar' uses reserved file or directory name 'lib'” 我在 Android 中创建 App Bundle 时出错:使用保留文件或目录名称“res” - I am getting error in creating App Bundle in Android: uses reserved file or directory name 'res' 无法使用 android 的 App Bundle 构建 Unity 应用程序。 文件使用保留文件或目录名称“res” - Can't build Unity app using App Bundle for android. File uses reserved file or directory name 'res' Android App Bundle 构建错误:保留文件 - Android App Bundle build error: reserved file Android Studio3.2 APK 构建错误 -> 保留文件或目录名称“lib” - Android Studio3.2 APK Build Error -> reserved file or directory name 'lib' 出现错误:文件“ic_launcher.png”使用保留文件或目录名称“res”。 在构建 Bundle 文件时 Android Studio - Getting Error: File 'ic_launcher.png' uses reserved file or directory name 'res'. while building Bundle file Android Studio 文件 'root/lib/META-INF/MANIFEST.MF' 使用保留文件或目录名称 'lib' - File 'root/lib/META-INF/MANIFEST.MF' uses reserved file or directory name 'lib' 构建捆绑包:构建捆绑包文件时出错–>文件'root / res / drawable / sr_list_item_background.xml'使用保留文件或目录名称'res' - Build Bundle(s): Errors while building Bundle file-->File 'root/res/drawable/sr_list_item_background.xml' uses reserved file or directory name 'res' 使用保留的文件或目录名称“ res” - uses reserved file or directory name 'res' Android错误:“文件'root / res / drawable-mdpi / popup_bottom_medium.9.png'使用保留的文件或目录名称'res'。” - Android Error: “File 'root/res/drawable-mdpi/popup_bottom_medium.9.png' uses reserved file or directory name 'res'.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM