Search code examples
android-studioaarandroid.mk

aar support in Android.mk.. the apk contain no R.java which packageName is aar


I am doing android custom ROM development. the app need an aar , reference aar support in Android.mk , I edit Android.mk then use 'mm -B' to build the app successfully.

But it Force Close when run the apk, which packageName is com.demo.android. Caused by: java.lang.ClassNotFoundException: Didn't find class "com.demo.aar.R"

"com.demo.aar" is the packageName for aar/library.

"com.demo.android" is the packageName for app.

I use the aar on AndroidStudio 1.5, the demo app run successfully.

then I compare the apk between android-studio and android.mk.

finally, I find that the apk built with Android.mk has no 'com.demo.aar.R' class, which apk built with AndroidStudio has. (they both has 'com.demo.android.R' class.)

so is this bug of Android.mk , OR I need more config in Android.mk??


Solution

  • 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.