-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libs file(*.so) inside split apk doesn't extracted to folder "lib" in App Bundle #39
Comments
From Android M, the Android platform supports uncompressed native libraries in APKs, which allows the platform to read the native libraries directly from the APK without having to extract them. This is why you don't see them in the "lib/" directory if you're testing on a device on Android M or later. Since the Android platform reads the native libraries from the APK directly, you should probably do the same if you need to verify something on them. There is a flag in Gradle to disable this feature but that leads to bigger APKs on users devices since the native libraries are extracted out of the APK (and thus also longer installation times), so unless there is no workaround for what you're trying to achieve, I would strongly discourage disabling it. |
Hy @plecesne thanks for your info and suggestion. |
@plecesne "There is a flag in Gradle to disable this feature" Could you give detail about this? I want to try disable it. |
You can set the property |
I just want to have more free space to push some data into apk |
By compressing the native libraries, the APKs served to your users will be bigger! I explained this a bit better in #118 Although the App Bundle looks bigger and the APK files look bigger, the compression performed over the wire will be more efficient, leading to smaller downloads, and the size on device will be saved as well since the platform will not have to extract it at install time (which would result in two copies of the native libraries on device: one compressed in the APK, and one uncompressed in the installation directory). Note also regarding size limits that the Play Console doesn't not validate the size based on the size of the App Bundle but based on the download size of the generated APKs, so compressing the native libraries doesn't gain you anything there either. |
@plecesne Thanks, but the correct property is We would like you to be aware that we couldn't use uncompressed native libs feature as we need to use the path of the .so files. For example, when we use pure data, a audio manipulating engine, we shall providing the native library path to its API for it to discover the custom Hope that makes sense. I wonder if there is a way to get valid native libraries path even if we keep native libs uncompressed in the apk. |
Ah, sorry about the name, I'll edit my comment in case somebody finds it later. Loading the library using |
Good to know that Until then,
|
Depending on non-Android SDKs may require you to leave APKs compressed indeed. Note that the warning you see was removed in 3.6 canary 3. |
you can use : |
|
I have tried with android.bundle.enableUncompressedNativeLibs=false, unfortunately it does not create lib/arm64 folder on release builds |
android { |
项目未配置 `useLegacyPackaging=true` 时, 使用AAB安装, 或最低版本为Android M以上的APK Native库不会从APK中解压, 参考: https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs google/bundletool#39 此时xCrash通过 `ctx.getApplicationInfo().nativeLibraryDir` 获取的目录内容是空的 因此会出现加载xcrash_dumper失败 而通过 PathClassloader.findLibrary(libName) 获取的路径是虚拟路径, 不是真实存在的 因此直接执行也会失败 此时我们参考 Crashpad 的逻辑, 使用linker加载 参考: https://github.com/chromium/crashpad/blob/main/client/crashpad_client_linux.cc#L114 为了避免大的改动, 默认仅在加载虚拟路径时使用linker, 实际上在所有场景都可以直接通过linker加载 支持外部自定义配置 ``` .setNativeLibPath() .setLoadNativeWithLinker() ``` 如果外部没有配置,内部会自动查找 参考: AbiPathProvider.java 逻辑
项目未配置 `useLegacyPackaging=true` 时, 使用AAB安装, 或最低版本为Android M以上的APK Native库不会从APK中解压, 参考: https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs google/bundletool#39 此时xCrash通过 `ctx.getApplicationInfo().nativeLibraryDir` 获取的目录内容是空的 因此会出现加载xcrash_dumper失败 而通过 PathClassloader.findLibrary(libName) 获取的路径是虚拟路径, 不是真实存在的 因此直接执行也会失败 此时我们参考 Crashpad 的逻辑, 使用linker加载 参考: https://github.com/chromium/crashpad/blob/main/client/crashpad_client_linux.cc#L114 为了避免大的改动, 默认仅在加载虚拟路径时使用linker, 实际上在所有场景都可以直接通过linker加载 支持外部自定义配置 ``` .setNativeLibPath() .setLoadNativeWithLinker() ``` 如果外部没有配置,内部会自动查找 参考: AbiPathProvider.java 逻辑
Hello team,
I have problem when try to read libs file (.so) within app bundle.
commonly, if we install installer file (.apk), this .apk file will be extracted in the device on folder data/app/packageName and inside it there are "lib" folder that contain libs file.
But when I installed app bundle and when bundle is extracted on the device my folder "data/app/mypackageName/lib" is empty. all my libs files (*.so) that I need still in splitApk.apk file
preview for extracted bundle file in device
preview for extracted .apk file in device
command that I used to install aps bundle is :
install-apks --apks=!BASENAME_PATH!.apks --modules=dlc_module
Question :
Could I get all libs(*.so) files such as if we use .apk file as installer? because I need this file to handle security system in my apps
If I couldn't , Could you please give me some advice?
Btw, sorry if my question is not clear enough, my english is very bad.
The text was updated successfully, but these errors were encountered: