Android/AOSP Android.mk 构建和支持-v4 AAR 等 [英] Android/AOSP Android.mk building and support-v4 AAR etc

查看:35
本文介绍了Android/AOSP Android.mk 构建和支持-v4 AAR 等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AOSP 构建一个应用,使其成为系统映像的一部分,并尝试将 support-v4 等库包含为 AARs 用于应用程序/在应用程序的 libs/ 文件夹中.否则这可以正常工作并且应用程序本身和整个系统映像构建正常,但是在尝试打开应用程序时会出现运行时崩溃.它们似乎都与在运行时找不到特定的 support-v4 等类有关,例如 ViewCompatMarshmallow 等.

I am building an app to be part of the system image with AOSP, and trying to include the support-v4 etc. libraries as AARs for the app / in the app's libs/ folder. Otherwise this works fine and the application itself and the whole system image builds OK, but then runtime crashes appear when trying to open the app. They all seem to be related to not finding specific support-v4 etc. classes during the runtime, such as ViewCompatMarshmallow etc.

现在,我检查了这些类实际上包含在 AAR 文件中,但是例如像这样:

Now, I checked and those classes are actually included inside the AAR file, but e.g. like this:

ViewCompat$MarshmallowViewCompatImpl.class

而如果我检查例如的源代码support-v4,它们被包含为

Whereas if I check the source code of e.g. the support-v4, they are included as

ViewCompatMarshmallow.java

所以不应该将其作为

ViewCompatMarshmallow.class

?

我怀疑这可能是某种 Android.mk 问题,因为这是我需要在我的应用程序中使用的问题.不幸的是,Gradle 不是一个选项.

I am suspecting that this could be some kind of Android.mk issue, since that is what I need to use with my app. Gradle is not an option unfortunately.

我已经声明例如根据需要使用 support-v4 AAR 库:

I have declared e.g. the support-v4 AAR library as needed:

LOCAL_STATIC_JAVA_AAR_LIBRARIES += support-v4-26.0.0

LOCAL_AAPT_FLAGS += --auto-add-overlay
LOCAL_AAPT_FLAGS += --generate-dependencies
LOCAL_AAPT_FLAGS += --extra-packages android.support.v4
LOCAL_AAPT_FLAGS += --extra-packages android.support.v4.app
LOCAL_AAPT_FLAGS += --extra-packages android.support.v4.view
(etc. all the required packagenames) 

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += support-v4-26.0.0:libs/support-v4-26.0.0.aar

AAR 文件本身来自 Android SDK 的 m2repository 文件夹,所以它应该是官方"和正确的,对吧?

The AAR file itself is from the Android SDK's m2repository folder, so it should be the "official" and proper one, right?

有什么想法吗?

谢谢!

推荐答案

回答我自己 - 问题是/是 AAPT/AAPT2 构建系统因从内部提取内容而被破坏*.aar 文件.

Answering myself - the issue was/is with the AAPT/AAPT2 build system being broken with what comes to extracting stuff from inside the *.aar files.

因此,如果您有例如*.aar 内的 libs/ 文件夹中的一些 *.jar 文件,该文件未被选取,然后导致运行时崩溃并带有 ClassDefNotFoundExceptions.

Thus, if you have e.g. some *.jar file inside the libs/ folder inside the *.aar, that is not picked up and that then results into runtime crashes with ClassDefNotFoundExceptions.

所以,基本上答案已经在这里了:如何使用 android 在 AOSP 中包含 .aar.马克

So, basically the answer was already here: How to include .aar in AOSP with android.mk

这篇关于Android/AOSP Android.mk 构建和支持-v4 AAR 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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