Android 8.1 include aar in AOSP

277 views
Skip to first unread message

George Vlahakis

unread,
Sep 27, 2020, 9:11:04 PM9/27/20
to Android Building
I need to add a couple of aar's in system/framework folder to be available by the custom device developers to use in their applications.

I have already managed to compile and include normal JAR files to this folder during AOSP build, but I am having trouble figuring out what needs to be the content of my Android.mk file to copy pre-built aar files to the system/framework.

Already added them in PRODUCT_BOOT_JARS.

Sample of my Android.mk:

include $(CLEAR_VARS)
LOCAL_MODULE := moduleName
LOCAL_SRC_FILES := moduleName.aar
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_SUFFIX := .aar

include $(BUILD_PREBUILT)

If I mm in the directory it creates the intermediates correctly but does not copy the result to the final image /system/framework


Luis Neri

unread,
Sep 27, 2020, 9:23:14 PM9/27/20
to android-...@googlegroups.com
Thanks ,🙏

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/a45e9306-514e-4408-9f62-23f4c6b762e0n%40googlegroups.com.

George Vlahakis

unread,
Sep 27, 2020, 9:23:15 PM9/27/20
to Android Building
Dear all,

I found that adding the module name to PRODUCT_PACKAGES at least copies the aar files in the target folder.

I do not know if it will now be possible to dynamically load the aar (like a jar) and use it in an APK. Will try and report with in.

Thanks

George Vlahakis

unread,
Sep 27, 2020, 11:55:20 PM9/27/20
to Android Building
Another update:

The aar ends up in the system/framework as expected. However, when I build an APK (using compileOnly linking to the aar for development) and then run it on the device, when I try to reference a simple class from the aar I get a ClassNotFound exception.

Didn't find class "blahblah" on path: DexPathList[[zip file "/data/app/blahblah-alZcI7F0c4pu3uaE3oKynw==/base.apk"],nativeLibraryDirectories=[/data/app/blahblah-alZcI7F0c4pu3uaE3oKynw==/lib/arm, /system/lib, /vendor/lib]]

I would have thought that having the package in PRODUCT_BOOT_JARS it would have added the aar file to the class path and would have allowed referencing it.

I read somewhere that aar files are not applicable for loading this way... 

George Vlahakis

unread,
Sep 27, 2020, 11:55:20 PM9/27/20
to Android Building
And the point around not being about to load classes runtime from a an aar: https://stackoverflow.com/questions/48716303/how-to-load-class-dynamically-from-aar-file-with-dexclassloader

The above principal at least should work for a jar file only... (for my needs I should be able to strip down to a jar file instead of aar).

I think to add resources to this approach one would need to overlay the framework's resources (out of scope for my needs)

Reply all
Reply to author
Forward
0 new messages