Skip to content Skip to sidebar Skip to footer

Android Studio: How To Add And Use Project As Library, Not As Module

I have 2 libraries: chilkat-9.5.0-android-all simple-file-chooser-master I have copied both into libs folder and used it as libs. When I try to import these libs into my java cl

Solution 1:

I implemented a .jar library today in my project and did the following:

  1. add the .jar file to the libs folder of your project

  2. in the build.gradle file add: compile fileTree(dir: 'libs', include: ['*.jar']) to the dependencies.

  3. Build your project

  4. now try to import the objects in your class :)

like this: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }

other thing you can try is: right mouse click on your .jar in Android Studio and select "make module". - and build again.

Solution 2:

Here is i did it and it worked for most libraries. Since the libraries have their own manifest files they have got to be used. Extract the master-zip elsewhere and copy only the library folder into your project direct folder where there is the app folder. When done then open the application settings.gradle file and edit it like below:

include':app', ':mylibrary'

Sync the project then open the build.gradle of your application then go to dependencies and add your library to it as below:

compile project(':mylibrary')

Sync the gradle with project then if any errors occur within the library gradle then open it and match it with your project data. Usually you would want to change compileBuildTools, sdk and other stuff. Happy coding

Post a Comment for "Android Studio: How To Add And Use Project As Library, Not As Module"