Reputation: 5
I have imported library module in my project. but I want to convert existing library module to a jar and then I want to use this jar(library module) in my current project.but I did this all process and trying to a specific class in my layout but The following classes could not be found: - com.halilibo.bettervideoplayer.BetterVideoPlayer, this error getting. The main issue is that jar file only contain java classes but module also contains resources, drawable also. I converted my module to jar but specific class is not getting imported.
Upvotes: 0
Views: 2204
Reputation: 3249
You need to create AAR
file instead of JAR
as you have to include resources.
Library reuse has long been available in Java based applications through Java Archive (.jar) files. Android AAR files build upon this concept to allow you to package not only the source code but also the libraries self contained Android resources. The library can have its own manifest and resources and can also optionally provide assets, NDK built libraries, proguard configuration and even its own custom lint filters. This is all bundled into a zip archive that can be published to a repository for your team (or the world!) to get easy access from a Gradle build.
One key difference in the created library and an Android application will be the libraries Gradle build script includes apply plugin: com.android.library
instead of apply plugin: com.android.application
.
When you build your project the AAR file will automatically be assembled and placed in these folders
| build
| outputs
| aar
| applib-debug.aar
| applib-release.aar
https://androidbycode.wordpress.com/2015/02/23/building-an-aar-library-in-android-studio/
Upvotes: 1