1

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.

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

ViewCompat$MarshmallowViewCompatImpl.class

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

ViewCompatMarshmallow.java

So shouldn't that then be included within the AAR as

ViewCompatMarshmallow.class

?

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.

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

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

Any ideas?

Thank You!

Androidish
  • 11
  • 1

1 Answers1

0

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.

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.

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

Androidish
  • 11
  • 1