I have an "aar" file that was generated using gradle with
apply plugin: 'com.android.library'
Now I want to use this aar library to create a cordova plugin. I unzip the aar file, get a "classes.jar" and put the jar into cordova's "libs" directory. My cordova project compiles without any problem, I can import and use classes in the jar file. But it crushed at run time with the following error
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/pkg/R$raw;
Package "com.example.pkg" is in my "classes.jar", but there is no class call "R$raw". What did I miss?
AAR files bundle not only source but also the libraries self contained Android resources. Take a look at the contents of an AAR bundle.
It appears the original AAR file you had contained some
raw
resources which are not included in the jar. You cannot package Android resources in a .jar file so your application is crashing when it needs to access the ID's generated for resources.You can check this by opening up the original AAR file (it is simply a zip archive). Take a look under the res folder for any resources that are needed by the library.