从APK中获取动态库路径并加载

apk会将jnilibs目录下得libs自动打包到APK中, 然后在APK运行得过程中进行加载并使用。我们怎么从apk中获取到我们得lib路径呢?

构建 Android App Bundle 时,由于 Android 6.0(API 级别 23)或更高版本为目标平台的 App Bundle 生成的 APK 现在默认包含原生库的未压缩版本。这项优化无需设备创建库的副本,因此减少了应用占用的存储空间。
如果您想要停用此优化,请在 gradle.properties 文件中添加以下代码:

android.bundle.enableUncompressedNativeLibs = false

这样在apk安装后, pms会将apk中得so都解压并存储到app data目录下;

如果在运行时候需要获取apk路径, 则可以参考如下方法:

    String arch = System.getProperty("os.arch");
    String apkPath = InstrumentationRegistry.getContext().getPackageResourcePath();
    if (arch.equals("aarch64")) {
      System.load(apkPath + "!/lib/arm64-v8a/libdynamiclinker_native_lib_b.so");
    } else if (arch.startsWith("arm")) {
      System.load(apkPath + "!/lib/armeabi-v7a/libdynamiclinker_native_lib_b.so");
    } else if (arch.equals("x86_64")) {
      System.load(apkPath + "!/lib/x86_64/libdynamiclinker_native_lib_b.so");
    } else if (arch.endsWith("86")) {
      System.load(apkPath + "!/lib/x86/libdynamiclinker_native_lib_b.so");
    } else {
      // Don't know which lib to load on this arch.
      return;
    }

About: kiah


149 thoughts on “从APK中获取动态库路径并加载”

  1. I am just writing to make you be aware of of the brilliant discovery my child encountered checking the blog. She came to understand a lot of details, including how it is like to have a marvelous coaching character to get certain people completely comprehend a variety of complex issues. You actually did more than her desires. I appreciate you for coming up with such essential, dependable, edifying and cool guidance on that topic to Ethel.

  2. A lot of thanks for all your valuable hard work on this web page. Kim really likes getting into investigation and it’s really easy to understand why. Many of us know all of the dynamic medium you make invaluable steps on this web blog and as well as improve participation from people on that idea so our girl is certainly learning a lot of things. Have fun with the remaining portion of the new year. You are conducting a pretty cool job.

  3. Needed to write you this very small word to help thank you very much yet again with your wonderful views you have shown on this website. This is so wonderfully open-handed with you to supply without restraint what exactly some people would have supplied for an electronic book to make some profit on their own, specifically since you might well have tried it in the event you wanted. Those tricks likewise worked to provide a great way to understand that the rest have the same zeal the same as my very own to understand whole lot more with respect to this problem. I think there are thousands of more pleasurable times up front for those who view your website.

  4. I intended to compose you a bit of note in order to give many thanks again about the awesome advice you’ve contributed above. It’s generous of people like you giving easily all a few individuals could have advertised as an e-book in making some bucks for their own end, and in particular considering that you could have done it if you considered necessary. The pointers as well served like the fantastic way to fully grasp other people have similar eagerness like my own to know great deal more on the topic of this issue. I am certain there are millions of more fun opportunities in the future for individuals who look over your blog post.

  5. I’m commenting to let you be aware of of the amazing discovery my child developed browsing the blog. She came to find a good number of details, including how it is like to have a great coaching character to get a number of people clearly completely grasp a number of advanced issues. You actually did more than her desires. I appreciate you for churning out such beneficial, dependable, edifying and cool guidance on that topic to Emily.

  6. My husband and i felt absolutely ecstatic Edward could complete his homework from the ideas he discovered from your very own site. It’s not at all simplistic just to be giving for free helpful tips that men and women could have been making money from. And we do know we have the blog owner to appreciate because of that. Most of the explanations you’ve made, the easy blog menu, the friendships you assist to engender – it’s everything excellent, and it’s assisting our son and our family do think that content is brilliant, and that’s extremely fundamental. Many thanks for all the pieces!

  7. I’m also commenting to let you be aware of of the cool discovery my child encountered checking your blog. She came to understand a wide variety of details, most notably how it is like to have a marvelous coaching heart to get folks easily fully grasp a variety of complicated matters. You actually did more than my desires. I appreciate you for delivering such good, dependable, edifying and also cool guidance on that topic to Evelyn.

  8. I simply wished to thank you very much yet again. I do not know what I would have worked on without those tricks shown by you relating to this topic. This was the troublesome situation in my view, nevertheless witnessing your well-written way you treated the issue took me to weep with joy. Now i am thankful for your work as well as wish you recognize what an amazing job your are undertaking training the rest with the aid of your websites. Probably you haven’t met any of us.

  9. My spouse and i got really joyous that Jordan managed to do his reports through your precious recommendations he had through the web pages. It is now and again perplexing to just find yourself handing out secrets and techniques which people may have been selling. So we keep in mind we have got the writer to give thanks to for that. The most important illustrations you have made, the simple web site navigation, the relationships you will help to foster – it’s got many overwhelming, and it’s really leading our son in addition to the family know that the situation is exciting, which is rather mandatory. Thank you for everything!

  10. I simply wished to thank you very much yet again. I do not know what I would have worked on without those ways shown by you relating to this topic. This was the troublesome situation in my view, nevertheless witnessing your well-written way you treated the issue took me to weep with joy. Now i am thankful for your work as well as wish you recognize what an amazing job your are undertaking training the rest with the aid of your websites. Probably you haven’t met any of us.

  11. I simply wished to thank you very much yet again. I do not know what I would have undertaken without these thoughts shared by you regarding this subject matter. It was before the scary scenario in my position, nevertheless taking note of this specialized tactic you solved the issue took me to weep with happiness. Now i’m thankful for your support and thus trust you really know what an amazing job you were putting in training the mediocre ones via your webpage. Most probably you haven’t met any of us.

  12. I simply wanted to thank you so much once more. I do not know what I would’ve sorted out without these strategies revealed by you over that subject. It was an absolute horrifying matter in my position, nevertheless spending time with this specialized style you resolved the issue took me to leap with happiness. I will be happy for your service and then sincerely hope you realize what an amazing job you have been providing teaching some other people using your web site. Most likely you haven’t got to know any of us.

  13. Today, with all the fast life style that everyone is having, credit cards have a big demand throughout the economy. Persons coming from every area of life are using credit card and people who aren’t using the credit cards have arranged to apply for 1. Thanks for revealing your ideas about credit cards. https://hypertensionmedi.com best hypertension with least side effects

  14. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  15. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  16. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  17. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  18. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  19. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  20. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  21. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  22. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  23. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  24. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  25. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  26. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  27. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  28. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  29. Холостячка 2 сезон https://bit.ly/39ioLkW Смотреть онлайн шоу Холостячка 2 сезон на СТБ.
    Пост шоу можно смотреть тут. Холостячка стб 2 сезон 1-2 серия

  30. Усик нокаутирует Джошуа – боксер Редкач JoshuaUsyk Джошуа больше, богаче и авторитетнее Усика, но может

  31. Усик разом з сестрами-близнючками презентували кліп на пісню Light up. У коментарях запропонували боксеру виходити під цю композицію на бій проти британського важковаговика Ентоні Джошуа. Энтони Джошуа Александр Усик Рен ТВ Джошуа назвал главную угрозу со стороны Усика – бой Усик

发表评论

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