Build AAR package as part of AOSP build

瀏覽次數:6,967 次
跳到第一則未讀訊息

adhiti

未讀,
2016年3月31日 上午10:48:142016/3/31
收件者:Android Building
Need information on building AAR package using AOSP build. What are the changes required in Android.mk to build AAR package?

For Ex: for static JAR we have include $(BUILD_STATIC_AAR_LIBRARY)
 to build static JAR.

Ying Wang

未讀,
2016年4月1日 下午1:03:452016/4/1
收件者:Android Building
The build system automatically sets up rule to build .aar when you  include $(BUILD_STATIC_AAR_LIBRARY) and the library has LOCAL_RESOURCE_DIR.
But it's not built by default. You need to run something like "make out/target/common/obj/JAVA_LIBRARIES/<library_name>_intermediates/javalib.aar to get it built.
 

--
--
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.
For more options, visit https://groups.google.com/d/optout.

satyanarayana Murthy desala

未讀,
2016年8月21日 下午4:55:512016/8/21
收件者:Android Building
Hi Adhiti,

I am also trying to build a module as AAR in AOSP build, Can you help me by sharing the mk file to achieve my task


Regards
Murthy

erik.gil...@gmail.com

未讀,
2017年4月25日 晚上11:15:112017/4/25
收件者:Android Building
Hi,

Can you please elaborate your answer? I failed to build an AAR with the instructions in your post/commit.

Regards
Erik

rajesh khetan

未讀,
2017年4月26日 上午10:36:202017/4/26
收件者:Android Building
Not able to build aar using $(BUILD_STATIC_AAR_LIBRARY) . Can you please post your Android.mk 


On Thursday, March 31, 2016 at 8:18:14 PM UTC+5:30, adhiti wrote:

Ankit Bhargava

未讀,
2017年9月4日 上午10:57:472017/9/4
收件者:Android Building
Do you able to build AAR package using AOSP build? is it possible to do so?

kush singh

未讀,
2017年11月17日 上午8:28:402017/11/17
收件者:Android Building
To build the AAR file from the AOSP build, you need to make the Android.mk file for the that lib like below:-


LOCAL_PATH := $(call my-dir)
include $
(CLEAR_VARS)

LOCAL_SDK_VERSION
:= current
LOCAL_MODULE_TAGS
:= optional

LOCAL_MODULE := YourLibName

LOCAL_STATIC_JAVA_LIBRARIES
:=android-common \
    android
-support-v4 \
    android
-support-design \
    android
-support-v7-appcompat \
    android
-support-design-res \
    android
-support-v7-cardview


LOCAL_STATIC_JAVA_AAR_LIBRARIES
:= name_of_any_aar_lib_your_using_your_lib

LOCAL_SRC_FILES
:= $(call all-java-files-under, java)

res_dirs
:= res \

LOCAL_RESOURCE_DIR
:= $(addprefix $(LOCAL_PATH)/, $(res_dirs)) \
    prebuilts
/sdk/current/support/v7/cardview/res \
    prebuilts
/sdk/current/support/v7/appcompat/res \
    prebuilts
/sdk/current/support/design/res \

LOCAL_AAPT_FLAGS
:= \
   
--auto-add-overlay \
   
--extra-packages android.support.v7.cardview \
   
--extra-packages android.support.v7.appcompat \
   
--extra-packages android.support.design \
   
--extra-packages package_name_of_any_aar_lib_your_using_your_lib


LOCAL_JACK_ENABLED
:= disabled
LOCAL_PROGUARD_ENABLED
:= disabled

include $(BUILD_STATIC_JAVA_LIBRARY)
##################################################
include $
(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES
:= prebuild_libs_if_any


include $
(BUILD_MULTI_PREBUILT)

include $
(call all-makefiles-under,$(LOCAL_PATH))

you need to use include $(BUILD_STATIC_JAVA_LIBRARY) instead of include $(BUILD_STATIC_AAR_LIBRARY) it worked for me
and save this make file with name Android.mk in you module, then to build use below command

make YourLibName out/target/common/obj/JAVA_LIBRARIES/YourLibName_intermediates/YourLibName.aar

Sebotor

未讀,
2018年1月18日 中午12:16:242018/1/18
收件者:Android Building
Hello,
I might be NOT understanding something...
Did anyone tried this yet or was successful on building aar library within the AOSP, which can be reused by other apps in the tree?  
I had been trying to build my custom aar library in the AOSP build for several weeks, but it doesn't work.  

1. With the "make YourLibName out/target/common/obj/JAVA_LIBRARIES/YourLibName_intermediates/YourLibName.aar", it gives me the following error
Starting build with ninja
ninja: Entering directory `.'
ninja: error: unknown target 'out/target/common/obj/JAVA_LIBRARIES/YourLibName_intermediates/YourLibName.aar'
make: *** [ninja_wrapper] Error 1

2. The only thing that works are the following commands
- In the the Library directory:
mm
- In the main directory:
make YourLibName

3. After the build, the following files get produced

in-out/target/poroduct/.../obj/JAVA_LIBRARIES/YourLibName_intermediates/
total 5668
rw-rw-r-- 1 sebotor sebotor 2428 Jan 18 07:45 javalib.jar
in-out/target/common/obj/JAVA_LIBRARIES/YourLibName_intermediates/
total 6064
drwxrwxr-x 4 sebotor sebotor   4096 Jan 18 07:45 classes
-rw-rw-r-- 1 sebotor sebotor   2428 Jan 18 07:45 classes-full-debug.jar
-rw-rw-r-- 1 sebotor sebotor   2428 Jan 18 07:45 classes.jar
-rw-rw-r-- 1 sebotor sebotor   2428 Jan 18 07:45 classes-jarjar.jar
-rw-rw-r-- 1 sebotor sebotor   2428 Jan 18 07:45 javalib.jar
-rw-rw-r-- 1 sebotor sebotor   3930 Jan 18 07:45 proguard_options
-rw-rw-r-- 1 sebotor sebotor 385622 Jan 18 07:45 public_resources.xml
drwxrwxr-x 4 sebotor sebotor   4096 Jan 18 07:45 src

According to the google docs, even if the aar (or zip) is not created and the files are in those directories, I would hope to see something that resembles the documentation:

Am I missing something or mis-understading?  Please let me know.

Thank you,

Sebotor

Tony Guo

未讀,
2018年6月4日 上午10:01:322018/6/4
收件者:Android Building
Hi, 

Instead of  make YourLibName out/target/common/obj/JAVA_LIBRARIES/YourLibName_intermediates/YourLibName.aar Could you please try

make YourLibName out/target/common/obj/JAVA_LIBRARIES/YourLibName_intermediates/javalib.aar

at least, it works on my AOSP build environment.

Kind regards,
Tony

Sebastian Tomaszewski

未讀,
2018年6月5日 下午1:02:272018/6/5
收件者:android-...@googlegroups.com
Hello Tony,
Thanks for the reply.  

I am NOT sure on whether or NOT that it works.  The problem that I had seen last June was related to the build environment that I am having with the AOSP tree.  Unfortunately I am stuck right now, because I can't update it (for various reasons).  Saying this, I found other work around this, by using other way to the things that I wanted to do.

Thanks,


Sebo

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-building@googlegroups.com

To unsubscribe from this group, send email to

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 a topic in the Google Groups "Android Building" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-building/htNXz9Lkq7E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-building+unsubscribe@googlegroups.com.

Vaibhav Shinde

未讀,
2018年8月25日 下午6:02:312018/8/25
收件者:Android Building
Hi Tony,

With these instruction I was able to build aar library using Android.mk, but how can we make aar library with Android.bp ?

Thanks,
Vaibhav

Ray

未讀,
2019年1月28日 下午6:26:432019/1/28
收件者:Android Building
Hi Tony,

It worked with your solution, I could get aar by using this command.  it seems it didn't work when I imported this aar into android studio. In my aar, I imported another jar by using 
include packages/services/xxx/xxx-lib/xxx.mk in my aar make file

This xxx.mk included support-annotations library, my app included implementation 'com.android.support:appcompat-v7', appcompat-v7 also included support-annotations. when I build it, I got below error:

AGPBI: {"kind":"error","text":"Program type already present: android.support.annotation.Dimension","sources":[{}],"tool":"D8"}

Do you guys know how to fix this kind of issue?

implementation(name:'mysdk', ext:'aar'){
exclude group: 'com.android.support', module:'support-annotations'
}

Unfortunately, it didn't work. Any suggestion for this error?

Thanks,
Ray
回覆所有人
回覆作者
轉寄
0 則新訊息