I know of Android Library projects, which allow you to create a shared-source project that can be pulled into Android Applications as needed. However, that requires that sou
Try this: This works
1) make your library project a normal project by deselecting IsLibrary flag.
2) Execute your project as Android Application. (It will not show any error)
3) you'll find a .jar file in bin folder along with .apk.
4) Give you .jar who want to use your library.
5) Tell them to just import external jar into build path.
this will works fine with all the resources. best of luck.
You can create a "regular" Java project and import from there Android.jar. Then, you will have access to every component in the SDK. Then, you can export your project as jar... and load it from your Android app. This works great and it seems a preety straightforward way to do it.
In the latest build of Android Studio 1.2, the creation of JAR library has been made as simple as point and click.
Steps to follow :
The next step is adding your Jar Library as dependency in your app. Simple as that just
....Or you could just add the below line to your App gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) // Default Gradle Task, should be already present
compile 'com.android.support:appcompat-v7:21.0.3' // Default Gradle Task, should be already present
compile project(':nameOfYourJarLibraryModule') // This is your jar library module
}
Google is promoting the Android Archive(AAR), even though JAR supported is brought back to android studio.To find out the difference between AAR and JAR refer this link
The only solution 'officially supported' by Google is the Library project, and it requires the source code to be distributed. You can create a JAR in the normal way, but you cannot include or reference resources within it.
Unfortunately I think it is also not possible to include a packaged JAR within a Library project, as a means to get around the source code requirement.
The ADT creates a bin folder which contains all of the class files for all matching source file and directories in your project, you could using the jar command,create a jar archive containing these class files and directories and presumable your library, but of course the class files platform level would only be targeted for current level of the project build- you would need a different jar file for each platform level; However the great thing about this is that the R.class file is include in the project directory tree and therefor you have access to its resources. I don't know if this is the official way to do things in android, but it worked for me.
In our project, we are creating apk (using apkbuilder) which is installed in /system/framework and added this apk in default classpath. For compilation of applications using the jar, we are creating a jar file (using jar c).
Note: We don't have any resources in the library.