How to enable downloaded from repositories libraries?


(Mikita Saladukha) #1

Hi everyone!
I’m new to Gradle and I have a question. Gradle allows us to use different libs, downloaded from various repositories. For example, I need android libs in java. I do the following: change my build.gradle file like:

apply plugin: ‘java-library’
apply plugin: ‘eclipse’

repositories {
maven { url “https://maven.google.com” }
jcenter()
google()
}

dependencies {
compile fileTree(dir: ‘libs’, include: [’*.jar’])
testCompile ‘junit:junit:4.12’
compile ‘com.android.support:appcompat-v7:24.2.0’
api ‘org.apache.commons:commons-math3:3.6.1’
implementation ‘com.google.guava:guava:23.0’
testImplementation ‘junit:junit:4.12’
}

What should I do next? How can I now use these downloaded android functions? If I try to directly call them from the gradle project, they become underlined by a red line. If I build a gradle project to a jar file(“Gradle Tasks\projectName\build\build\Run Gradle Tasks”, build successful), I cannot call this android functions from that jar file (by import, called with added jar file to a build path of a project). So how can I use downloaded functions?