john doe
john doe

Reputation: 9690

How to Import jar file into an Android project?

I am trying to use the loopj library in my Android project. In the project home page it says "Download the latest .jar file from github and place it in your Android apps libs folder". I did that!

As indicated in the documentation of the loopj I try to import it using the following

import com.loopj.android.http; 

and nothing happens. It is not even coming up in intellisense.

Am I doing anything wrong?

enter image description here

Upvotes: 1

Views: 1683

Answers (3)

Yasir Ali
Yasir Ali

Reputation: 1804

To let the Android Studio load all of your jar files by itself automatically, just write this line in the dependency section

compile fileTree(dir: 'libs', include: ['*.jar'])

This will help android studio to load all of your jar files available in libs folder.

Upvotes: 0

Jorgesys
Jorgesys

Reputation: 126563

into the build.gradle file add the following::

dependencies {
    // ... other dependencies
    compile files('libs/<your jar's name here>')
}

Rebuid your project or Run ./gradlew assemble. This should compile the project with the library.

Upvotes: 1

Nathua
Nathua

Reputation: 8836

in the build.gradle file add your jar such as below then rebuild.

dependencies {
    compile files('libs/android-async-http-1.4.4.jar')
}

Upvotes: 3

Related Questions