Home > other >  how to import Library in Android Studio
how to import Library in Android Studio

Time:11-12

i'm new in Android Development and try to import some libraries in Android Studio for example.

import android.content.om.OverlayInfo; 

if i try to use it i got the message "cannot resolve symol 'om'". i tried to copy some file in into the project but i still got the same messange

how do i do it correctly?

CodePudding user response:

Try this:

File -> Project Structure -> Dependencies Tab -> Add module dependency (scope = compile)

Where the module dependency is the project library Android folder.

CodePudding user response:

There are three ways to do it

  1. Adding Gradle Dependency

//for example i'm using picasso
implementation 'com.squareup.picasso:picasso:2.71828'

  1. Adding .jar/.aar Dependency

In some cases, we don’t get the Gradle dependency of the library. Instead, we get only the .jar/.aar file. In such case you can follow the below steps:

  • Find the .jar/.aar file and download it.

  • Then copy the file from the downloaded location and go to Android Studio.

  • Go to the App module and paste the file inside the libs folder. (If you don’t see the libs folder, create a new directory inside the App module.)

  • And then add this to Module app Gradle

    implementation fileTree(dir: 'libs', include: ['.aar', '.jar'], exclude : ['mock.jar'])

  1. Adding dependency as a module
  • Go to File -> New -> Import Module -> Select the library path -> Finish.

  • Then right-click on the App directory -> Open Module Settings -> Dependencies -> Click on button inside Declared Dependencies -> Module Dependency -> Select your library -> Ok.

  • Related