简体   繁体   中英

“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 .

The aar contains the information of what files should be considered as Android resources, native libraries, etc. in the app. A jar is just a plain list of files without Android concept. 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.

Try to package that library as an .aar instead of a .jar . See this documentation: 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.

Ok it is working now! Steps I used to found the problem (thanks for pointing me in the right direction @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.

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).

Going upwards on the dependency tree I realized it was caused by the 'io.voucherify.android.client:voucherify-android-sdk:2.1.0' dependency.

I just added @aar at the end of the dependency implementation, and I managed to build the app bundle.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM