如何只从AAR导入选定的本地库ABI? [英] How to import only selected native library ABIs from AAR?

查看:244
本文介绍了如何只从AAR导入选定的本地库ABI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一点不寻常的问题 - 我的Android应用程序包含本机库,并为armeabi-v7a和x86构建本机库。但是,现在我需要将第三方库集成到我的应用程序中,该应用程序还包含本地库(第三方库是我包括的 Crashlytics 通过Maven从我的build.gradle。)。问题是第三方库的AAR提供了所有arhitecture(armeabi,arm64-v8a,armeabi-v7a,mips,mips64,x86和x86_64),而我的应用只支持armeabi-v7a和x86(arm64-v8a计划在不久的将来) ,所以当最终apk建立时,它包含第三方库的所有ABI,并且只包含我的本机代码的x86和armeabi-v7a ABI。这会导致我的应用程序在像Galaxy S6这样的arm64设备上启动时崩溃。



我的问题是:是否可以只包含来自第三方AAR的选定ABI?



请注意,我知道 APK分割,但这只能部分解决我的问题,即它只在我通过Play商店分发我的应用程序时才起作用。虽然Play Store支持Beta测试版发布,但更新APK的传播速度非常缓慢,因此,在推出应用PlayStore beta版频道更新之前,我们会通过Crashlytics的beta版分发系统推送更新,速度更快。问题是Crashlytics的分配系统不支持APK分割(或者我错了吗?)。因此,我实际上需要构建一个只包含选定ABI的通用APK。如何实现这一目标?



尽管我对Crashlytics的特定答案(例如,如何通过他们的beta频道分发APK分裂)感到满意,但我会对构建仅包含选定ABI的通用APK的解决方案感到满意,因为在我们公司,我们还向我们的客户提供SDK作为仅包含受支持体系结构的AAR存档,并且我们想要告诉他们如何处理将我们的SDK与其他支持不同ABI的SDK集成。

我使用的是最新的稳定Android工作室(1.2.1.1),gradle 2.4和Android gradle插件1.2.3 。

解决方案

  packagingOptions {
exclude'lib / arm64-v8a / libcrashlytics
排除'lib / arm64-v8a / libcrashlytics.so'
排除'lib / armeabi / libcrashlytics-envelope.so'
排除'lib / armeabi / libcrashlytics.so '
排除'lib / mips64 / libcrashlytics-envelope.so'
排除'lib / mips64 / libcrashlytics.so'
排除'lib / mips / libcrashlytics-envelope.so'
排除'lib / mips / libcrashlytics.so'
排除'lib / x86_64 / libcrashlytics-envelope.so'
排除'lib / x86_64 / libcrashlytics.so'
}


I have a bit unusual problem - my Android app contains native libs and I build native libs for armeabi-v7a and x86. However, now I need to integrate a third party library into my app which also contains native libraries (third party library is Crashlytics which I included via Maven from my build.gradle.). The problem is that third party library's AAR provides all arhitectures (armeabi, arm64-v8a, armeabi-v7a, mips, mips64, x86 and x86_64) and my app only supports armeabi-v7a and x86 (arm64-v8a is planned for near future), so when final apk is built it contains 3rd party library's all ABI's and only x86 and armeabi-v7a ABI's of my native code. This causes my app to crash when launched on arm64 device like Galaxy S6.

My question is: is it possible to include only selected ABI's from 3rd party AAR?

Please note that I am aware of APK splits, but this only solves my problem partially, i.e. it works only if I distribute my app via Play Store. Although Play Store supports beta test distribution, the propagation of updated APK is rather slow, so prior pushing an update to app's PlayStore beta channel, we push an update via Crashlytics' beta distribution system, which is much faster. The problem is that Crashlytics' distibution system does not support APK splits (or am I wrong?). Therefore, I actually need to build an "universal" APK that will contain only selected ABIs. How to achieve that?

Although I would be satisfied even with Crashlytics'-specific answers (like for example, how to distribute APK splits via their beta channel), I would be much more satisfied with solution for building "universal" APK that contains only selected ABIs, because at our company we also provide SDKs to our clients as AAR archives that contain only supported architectures and we would like to instruct them how to handle case when they integrate our SDK with other SDKs that have different ABI's supported.

I am using latest stable Android studio (1.2.1.1), gradle 2.4 and android gradle plugin version 1.2.3.

解决方案

packagingOptions {
    exclude 'lib/arm64-v8a/libcrashlytics-envelope.so'
    exclude 'lib/arm64-v8a/libcrashlytics.so'
    exclude 'lib/armeabi/libcrashlytics-envelope.so'
    exclude 'lib/armeabi/libcrashlytics.so'
    exclude 'lib/mips64/libcrashlytics-envelope.so'
    exclude 'lib/mips64/libcrashlytics.so'
    exclude 'lib/mips/libcrashlytics-envelope.so'
    exclude 'lib/mips/libcrashlytics.so'
    exclude 'lib/x86_64/libcrashlytics-envelope.so'
    exclude 'lib/x86_64/libcrashlytics.so'
    }

这篇关于如何只从AAR导入选定的本地库ABI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆