Android APK从M开始不再支持安装后解压动态库

 

使用的三方动态库, 需要额外传入动态库加载路径, 不过在更新Android Studio后发现原本正常使用的APP无法找到对应的动态库导致APP闪退,也就是Android APP无法使用ApplicationInfo.nativeLibraryDir(/data/app/package/lib)来表示加载库路径。

问题描述

打包在APK的native libraries 不会再在安装的时候从apk解压缩,而是会从apk直接读取。这个功能实在Android M开始支持的额。APK 确保原生动态库不会从apk中解压缩出来, 以达到节省存储空间的目的。 一般来讲, 对于动态库的加载是无感的,也就是APP并不需要care这个过程,但是对于需要额外提供搜索路径的动态库却是致命的。原因就是这个地址不再是固定的,或者是透过ApplicationInfo.nativeLibraryDir可以拿到。使用ApplicationInfo.nativeLibraryDir得到的将会是个空目录的内容, 对应的动态库并不会被拷贝。

解决方法

对于单纯加载动态库, 可以无差别使用dlopen, 也即LD默认会搜索APK中为解压缩的动态库。对于需要传入ld libray path的, 需要支持解压缩动态库的可以参考如下方法:

  1. Update gradle.properties with android.bundle.enableUncompressedNativeLibs=false
  2. In the manifest under <Application> specify android:extractNativeLibs="true"

测试可以正常从apk解压缩出来

标签:

About: kiah


20 thoughts on “Android APK从M开始不再支持安装后解压动态库”

  1. I’m also commenting to let you be aware of of the excellent discovery my cousin’s child enjoyed checking your blog. She discovered a wide variety of details, most notably how it is like to have a marvelous coaching heart to get many more effortlessly fully understand certain complicated matters. You actually did more than my desires. I appreciate you for displaying such great, healthy, educational and also cool guidance on that topic to Evelyn.

  2. I am also commenting to let you know of the great encounter my friend’s daughter found reading through your web page. She figured out numerous issues, not to mention what it’s like to have an amazing giving mood to have men and women really easily have an understanding of selected hard to do subject areas. You really exceeded our own expectations. Many thanks for imparting the interesting, safe, explanatory and even easy thoughts on the topic to Janet.

  3. A lot of thanks for all your efforts on this site. Gloria enjoys doing investigation and it’s easy to understand why. Almost all know all concerning the dynamic means you deliver great items on the web blog and as well encourage contribution from other people on that concern plus our daughter is actually being taught a lot. Have fun with the remaining portion of the new year. You’re the one conducting a glorious job.

  4. I needed to send you the very little remark to finally thank you the moment again over the remarkable tactics you have shared on this page. This has been simply surprisingly open-handed with you to offer unhampered what most of us would’ve offered for sale for an ebook to help make some money on their own, precisely seeing that you might have tried it in case you desired. Those suggestions in addition worked to become good way to realize that some people have the identical keenness similar to my personal own to realize significantly more when it comes to this matter. I believe there are several more pleasant sessions up front for people who scan your site.

  5. My husband and i ended up being cheerful Albert could carry out his analysis because of the ideas he acquired from your blog. It’s not at all simplistic just to always be freely giving facts a number of people could have been making money from. And now we acknowledge we’ve got the blog owner to appreciate because of that. All of the explanations you’ve made, the easy blog menu, the friendships you aid to create – it’s all amazing, and it’s aiding our son and our family believe that that article is amusing, and that’s especially essential. Many thanks for all!

  6. My husband and i felt absolutely excited Emmanuel could conclude his inquiry from your ideas he gained in your site. It’s not at all simplistic just to always be giving away guidelines many others could have been making money from. And now we consider we’ve got the blog owner to appreciate because of that. All the explanations you’ve made, the easy blog menu, the friendships you aid to create – it’s all astounding, and it’s aiding our son and our family consider that that concept is awesome, and that’s exceptionally essential. Many thanks for all!

  7. Thanks for the advice on credit repair on this excellent site. Some tips i would tell people should be to give up the particular mentality that they may buy currently and shell out later. Being a society many of us tend to try this for many issues. This includes vacation trips, furniture, along with items we wish. However, you’ll want to separate your current wants out of the needs. If you are working to boost your credit score actually you need some trade-offs. For example you’ll be able to shop online to save cash or you can look at second hand merchants instead of high-priced department stores pertaining to clothing.

  8. My wife and i were so relieved when Michael managed to finish up his studies via the precious recommendations he obtained using your web site. It is now and again perplexing to simply happen to be offering things which often some people might have been trying to sell. We remember we now have you to thank for this. The type of illustrations you made, the straightforward website navigation, the relationships your site make it easier to promote – it is mostly spectacular, and it is letting our son in addition to us recognize that this subject matter is pleasurable, which is certainly truly serious. Thanks for the whole thing!

  9. Thanks for the recommendations on credit repair on this amazing site. A few things i would tell people is always to give up the actual mentality they can buy today and pay out later. Like a society we all tend to do that for many issues. This includes getaways, furniture, and also items we would like. However, you should separate the wants out of the needs. While you’re working to raise your credit score make some sacrifices. For example it is possible to shop online to save cash or you can visit second hand retailers instead of pricey department stores regarding clothing.

  10. I’m just commenting to let you be aware of of the fabulous discovery my cousin’s daughter experienced going through your site. She even learned lots of issues, most notably how it is like to have a very effective giving mindset to have many others just gain knowledge of chosen grueling matters. You really did more than our desires. Many thanks for distributing the important, healthy, educational and as well as easy thoughts on the topic to Gloria.

  11. Thanks for your strategies. One thing really noticed is that often banks plus financial institutions know the dimensions and spending patterns of consumers plus understand that plenty of people max outside their cards around the trips. They correctly take advantage of this real fact and then start flooding a person’s inbox plus snail-mail box by using hundreds of no interest APR credit cards offers shortly when the holiday season closes. Knowing that when you are like 98% in the American general public, you’ll get at the one opportunity to consolidate financial debt and switch balances towards 0 rate credit cards. poonmpp https://headachemedi.com – migraine headache drugs

  12. Thanks for your ideas. One thing I have noticed is that banks and financial institutions know the spending habits of consumers and understand that most people max out their credit cards around the holidays. They wisely take advantage of this fact and start flooding your inbox and snail-mail box with hundreds of 0 APR credit card offers soon after the holiday season ends. Knowing that if you are like 98% of the American public, you’ll jump at the chance to consolidate credit card debt and transfer balances to 0 APR credit cards. cccbbbi https://headachemedi.com – Headache pain medications

  13. I definitely wanted to jot down a brief message so as to express gratitude to you for all the lovely instructions you are placing at this website. My extended internet investigation has at the end been compensated with excellent details to exchange with my co-workers. I ‘d assume that many of us readers actually are quite blessed to be in a fantastic community with many brilliant individuals with good guidelines. I feel pretty fortunate to have come across the web page and look forward to plenty of more brilliant minutes reading here. Thank you again for a lot of things. https://bronchitismed.com best bronchitis meds

发表评论

电子邮件地址不会被公开。