Android Studio: How To Add And Use Project As Library, Not As Module
Solution 1:
I implemented a .jar library today in my project and did the following:
add the .jar file to the libs folder of your project
in the build.gradle file add:
compile fileTree(dir: 'libs', include: ['*.jar'])
to the dependencies.Build your project
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"