How can I add one library
using gradle
or not, in this particular case it is about adding the library to be able to use objects of the type JSONObject
to be able to test a code.
Question made based on this answer/question:
How can I add one library
using gradle
or not, in this particular case it is about adding the library to be able to use objects of the type JSONObject
to be able to test a code.
Question made based on this answer/question:
For the JSONObject, which is the one we will use as a case:
If you know the address, in this case it would be 'org.json:json:20151123' where the numbers correspond to its version, that is the one we will use, if we cannot consult this page:
http://mvnrepository.com/artifact/org.json/json/20151123
For example, where you can see several instructions, we select the one that is about
gradle
and we will see something similar to the previous one ('org.json:json:20151123').Now in your project we open
build.gradle file
it and add the following instruction along with the one we got earlier. (compile 'nombreLibraryDireccion'
)We synchronize and it should work for you, keep in mind not to have the offline option activated for gradle in the preferences.
You can also add it in the following way, obtaining the
.jar
onelibrary
you want, in this case we continue with the previous one, obtaining the jar after downloading it to our computer.We open and
copiamos
the json-20151123.jar file in the following path:Now in the
build.gradle file
and add the following statement (compile files ('libs/nombreDelFichero.jar');
):