Konstantin Luzan's answer has a problem. After compilation, the resources in aar will be added to my main package R file, but not to the RAR file of the AAR package. For example, the package name aar is my.aar, the main name of the project package is my.main. Aar has a string named "string_in_aar". After compilation, the line identifier is my.main.R.string_in_aar, not my.aar.R.string_in_aar. This causes apk to crash because the code in aar uses my.aar.R.string_in_aar.
The solution is to use: LOCAL_AAPT_FLAGS + = --extra-packages {package name aar}. You will get two R. files. They have some content. One package is the main package, the other is the aar package.
qhdwangnan
source share