I built one android studio project. I wanted to use it as a library in another project. I followed below steps for same:
- Changed apply plugin: 'com.android.application' to 'com.android.library'
- Removed applicationId from defaultConfig{}
- Clicked on sync
This gave me .aar file in build-->outputs-->aar-->myapp.aar
I imported this .aar file in my other test project. I followed below steps for this:
- File-->New-->New module-->Import .jar/.aar package-->myapp.aar
- In build.grade of test application added compile project(path: ':myapp')
- Clicked on sync.
This produced one folder inside external libraries called myapp-unspecified. There i get all res files but i did not get the class files inside classes.jar. Inside classes.jar I only have MANIFEST.MF.
Am I doing something wrong or am I missing something??
Experienced the same problem. My issue was that I had removed a dependency from my library project (in this case,
testCompile 'junit:junit:4.12'
), but did not delete the directory and classes that referenced the APIs from that dependency. Anaar
file was output to the build folder, but I was not able to access its contents when I included it in my application project.After deleting the unused classes and directories and re-syncing my library project, I was able to produce a working
aar
.