Ela*_*vin 3 android android-ndk android-studio android-app-bundle
I am trying to migrate my app from a monolithic APK to the app bundle format. I need to set LD_LIBRARY_PATH
environment variable for an exec()
call, therefore I need the location of my native libraries. With the original APK I would call getApplicationInfo().nativeLibDir
and the libraries were there.
With the app bundle they are not. I can see the correct abi split APK installed, but for some reason the libraries are not extracted.
I have tried installing with bundletool
and through Google Play,
Tried to run 'ls -alR'
and I can clearly see the directory exists as well as the split apk, but the libraries are simply not extracted. I guess I could extract them manually as a workaround but that would seem unnecessary..?
Here is the output of ls
on the parent folder of nativeLibPath
genLibraryPath: Dir Contents: /data/app/com.unseenonline-raAFLhJMQpjqWkVdG1Vocg==:
total 16704
drwxr-xr-x 4 system system 4096 2019-06-11 12:41 .
drwxrwx--x 114 system system 12288 2019-06-11 12:41 ..
-rw-r--r-- 1 system system 5688352 2019-06-11 12:41 base.apk
drwxr-xr-x 3 system system 4096 2019-06-11 12:41 lib
drwxrwx--x 3 system install 4096 2019-06-11 12:41 oat
-rw-r--r-- 1 system system 11226112 2019-06-11 12:41 split_config.arm64_v8a.apk
-rw-r--r-- 1 system system 35636 2019-06-11 12:41 split_config.en.apk
-rw-r--r-- 1 system system 90443 2019-06-11 12:41 split_config.xxhdpi.apk
/data/app/com.unseenonline-raAFLhJMQpjqWkVdG1Vocg==/lib:
total 24
drwxr-xr-x 3 system system 4096 2019-06-11 12:41 .
drwxr-xr-x 4 system system 4096 2019-06-11 12:41 ..
drwxr-xr-x 2 system system 4096 2019-06-11 12:41 arm64
/data/app/com.unseenonline-raAFLhJMQpjqWkVdG1Vocg==/lib/arm64:
total 16
drwxr-xr-x 2 system system 4096 2019-06-11 12:41 .
drwxr-xr-x 3 system system 4096 2019-06-11 12:41 ..
Run Code Online (Sandbox Code Playgroud)
As you can see the split apks are there but the libraries are not extracted.
Libraries should be extracted to the same location as they were with the original apk
默认情况下,从Android App Bundle生成的APK具有在Android P +的设备上未压缩的本地库。由于Android平台可以直接从APK读取本机库,而不必将它们提取到单独的位置,因此这不仅通常会减少下载大小,而且还大大减少了设备上应用程序的大小。在最后的I / O上,有一个关于如何减小应用程序大小以及如何影响安装数量的演讲,他们详细介绍了如何在您有兴趣更好地理解应用程序的情况下工作。
因此,既然您知道为什么Google Play会这样做了,那么您可以选择以下选项:
您可以选择还原为原始的APK行为,这可以通过android.bundle.enableUncompressedNativeLibs=false
在gradle.properties文件中添加标志来完成。这将有效地禁用此优化,从而为M +上的所有用户提供更大的应用程序大小。
您可以确保本机库是由Android平台加载的(例如使用System.loadLibrary
),或者如果您出于某种原因直接读取该库,也可以直接从APK读取该库。
如果本机库是由您依赖的第三方库加载的,请考虑为它们提交错误以解决此问题,以便它们遵循与平台相同的逻辑。
希望能有所帮助,
归档时间: |
|
查看次数: |
617 次 |
最近记录: |