We can find some very good open source libraries for android. I want to know what is the best way to integrate them to our own projects in Android studio. Here are some basic methods:
Is there a general rule to add third party source or jar files into an existing android studio project? Thanks
Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Library Dependency in the dropdown. In the Add Library Dependency dialog, use the search box to find the library to add.
In a nutshell, by using third party API, you can add new features to your app, get access to other services data or mobile device features, without spending a fortune on developing those features from scratch.
I prefer to use central repository for dependencies management. So for gson 2.3
dependency you should add to build.gradle
file:
Specify that you want to use maven central repository for your dependency
repositories {jcenter()}
Add compile
dependency to gson 2.6.2
dependencies {compile 'com.google.code.gson:gson:2.6.2'}
Android Studio as well as your CI server should easily build your project now. And you can continue app development.
I prefer to use central repository for dependencies management because:
Examples:
I should notice:
gson-2.2.4.jar
) into the libs foldercompile files('libs/gson-2.2.4.jar')
is in your build.gradle
filegradlew clean
. I'm on Mac OS X, the command might be different on your system This series of steps was taken from Android Studio: Add jar as library? and is not my original answer. I am posting them here, again, because your question was the third in search results on Google when looking up this same topic. Hence, copying.
All credits to the one who wrote the steps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With