aar support in Android.mk

后端 未结 3 2026
终归单人心
终归单人心 2020-12-08 12:03

I am doing android custom ROM development now. the build system of aosp is based on Android.mk, But I want to include some aar libraries, is it possible to include aar libar

3条回答
  •  鱼传尺愫
    2020-12-08 12:45

    Kostiantyn Luzan's answer has a problem. After compile, the resources in the aar will be added to my main package's R file, but not in the aar package's R file. For example, the aar's package name is my.aar, the main project's package name is my.main. The aar has a string named "string_in_aar". After compile, the strings id is my.main.R.string_in_aar rather than my.aar.R.string_in_aar. This makes the apk crash, because the code in the aar uses my.aar.R.string_in_aar.

    The solution is use: LOCAL_AAPT_FLAGS += --extra-packages {aar package name}. You will get two R file. They has the some content. One's package is the main package, the other is the aar package.

提交回复
热议问题