0

I want to use "slib-dist-0.9-all-jar" for my android project.

I downloaded the jar from semantics measure library and copied it in my android project/apps/libs folder. and in gradle , added a line as "compile files('libs/slib-dist-0.9-all-jar')" but it says that it is not a jar file . I also tried directly giving gradle build with
compile group: 'com.github.sharispe', name: 'slib-sml', version: '0.9.1' but in this case also it says

Unrecognized dependency: 'com.github.sharispe:slib-graph:0.9.1' (type: 'pom', extension: 'pom').

Please help is there something i can do to use it as jar file and not pom?

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile files('libs/slib-dist-0.9-all-jar')  //OR THIS
compile group: 'com.github.sharispe', name: 'slib-sml', version: '0.9.1'
}
Nikhil
  • 3,711
  • 8
  • 32
  • 43
Jana
  • 189
  • 1
  • 3
  • 13

2 Answers2

0

Finally, after lots of research and trials I found a solution over this, Follow this steps to add slib-dist-0.9-all-jar.jar or any external jar file to your android studio project:-

  • Step 1: copy the jar file and paste it into **Project_Location\app** directory in your project.
  • Step 2: Goto Android Studio -> then click on file menu -> Goto Project Structure -> Goto dependencies tab -> click plus button to add new dependency -> select file dependency -> then select the jar file (slib-dist-0.9-all-jar.jar) which we copied in the Project_Location/app/ directory -> click ok -> clean and build the project
  • Step 3: dependency will be added automatically in the gradle file of project.

Gradle dependencies will be like this :-

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile files('slib-dist-0.9-all-jar.jar')
}

Screenshots are given below :-

Step 1 :- Copy and Paste jar file enter image description here

Step 2 :- Add dependency enter image description here

Step 3 :- gradle file after clean and build enter image description here

Hope this will help you.

Priya Jagtap
  • 1,023
  • 13
  • 19
0

If you are using Android Studio, please check the accepted answer here: Android Studio: Add jar as library?

The line compile group: 'com.github.sharispe', name: 'slib-sml', version: '0.9.1' seems unnecessary (This is used for External respositories like Maven/JCenter etc. Not required for a jar file).

Community
  • 1
  • 1
PhoBi
  • 36
  • 3