Adding external library in Android studio

前端 未结 19 1089
面向向阳花
面向向阳花 2020-11-22 05:51

I want to add external library https://github.com/foursquare/foursquare-android-oauth to my Android application (I use Android Studio, the instructions provided by lib autho

相关标签:
19条回答
  • 2020-11-22 06:21

    Turn any github project into a single line gradle implementation with this website

    https://jitpack.io/

    Example, I needed this project: https://github.com/mik3y/usb-serial-for-android

    All I did was paste this into my gradle file:

    implementation 'com.github.mik3y:usb-serial-for-android:master-SNAPSHOT'
    
    0 讨论(0)
  • 2020-11-22 06:25

    I had the same problem. This happened because of core library dependency. I was using javax.* . This is what i did to fix

    In File->Project Structure->Dependencies I added this as as provided file, not a compile. Then re build the project.

    This problem started after upgrade of android studio. But I think it happens when you try to edit you build files manually.

    0 讨论(0)
  • 2020-11-22 06:27

    There are two simplest ways if one does not work please try the other one.

    1. Add dependency of the library inside dependency inside build.gradle file of the library you are using, and paste your library in External Libraries.

    OR

    1. Just Go to your libs folder inside app folder and paste all your .jar e.g Library files there, Now the trick here is that now go inside settings.gradle file now add this line include ':app:libs' after include ':app' it will definitely work.
    0 讨论(0)
  • 2020-11-22 06:28

    I had also faced this problem. Those time I followed some steps like:

    1. File > New > Import module > select your library_project. Then include 'library_project' will be added in settings.gradle file.

    2. File > Project Structure > App > Dependencies Tab > select library_project. If library_project not displaying then, Click on + button then select your library_project.

    3. Clean and build your project. The following lines will be added in your app module build.gradle (hint: this is not the one where classpath is defined).

     dependencies {
         compile fileTree(dir: 'libs', include: ['*.jar'])
         compile project(':library_project')
     }
    
    1. If these lines are not present, you must add them manually and clean and rebuild your project again (Ctrl + F9).

    2. A folder named library_project will be created in your app folder.

    3. If any icon or task merging error is created, go to AndroidManifest file and add <application tools:replace="icon,label,theme">

    0 讨论(0)
  • 2020-11-22 06:29

    1)just get your lib from here http://search.maven.org/

    2)create a libs folder in app directory

    3)paste ur library there

    4)right click on ur library and click "Add as Library"

    5)thats all u need to do!

    I hope this will definitely gonna help you!!!!

    0 讨论(0)
  • 2020-11-22 06:30

    Try this:

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

    Where the module dependency is the project library Android folder.

    0 讨论(0)
提交回复
热议问题