How do I add a library project to Android Studio?

前端 未结 30 3988
梦谈多话
梦谈多话 2020-11-21 04:24

How do I add a library project (such as Sherlock ABS) to Android Studio?

(Not to the old ADT Eclipse-based bundle, but to the new Android Studio.)

相关标签:
30条回答
  • 2020-11-21 04:51

    Add this in your build gradle file:

     dependencies {
         implementation 'com.jakewharton:butterknife:9.0.0'
    }
    
    0 讨论(0)
  • 2020-11-21 04:52

    Here is the visual guide:

    Update for Android Studio 0.8.2:

    In Android Studio 0.8.2, go to Project Structure -> under Modules just hit the plus button and select Import Existing Project and import actionbarsherlock. Then synchronise your Gradle files.

    If you face the error

    Error: The SDK Build Tools revision (xx.x.x) is too low. Minimum required is yy.y.y

    just open the build.gradle file in actionbarsherlock directory and update the buildToolsVersion to the suggested one.

    android {
      compileSdkVersion 19
      buildToolsVersion 'yy.y.y'
    

    Android Studio 0.8.2


    Menu File -> Project Structure...:

    First

    Module -> Import Module

    Second

    After importing the library module, select your project module and add the dependency:

    Third

    And then select the imported module:

    Forth

    0 讨论(0)
  • 2020-11-21 04:52

    Indeed as versions are changing, so is changing the user interface and options available on the menu. After reading most of the answers to these questions I had to guess what would work for Android Studio 1.1.0.

    1. With your mouse, select the project at the main level (this is where it shows the name of your app).

    2. Right click, and select the menu options New, Folder, Assets Folder.

    3. After creating the assets folder, paste or copy in it, whatever JAR file you need for your library.

    4. From Android Studio's main menu (top of the screen) select File -> Project Structure.

    5. Then select your project name and go to the Dependencies tab.

    6. Click on the plus sign (+) on the lower left of the dialog box and select file dependency.

    7. Finally open the recently created assets folder, select the JAR files that you copied, and then click apply and OK.

    Clean and rebuild your project.

    0 讨论(0)
  • 2020-11-21 04:53

    Basically, you can include your JAR files in three different ways. The last one is remote library that is using https://bintray.com/ jcenter online repository. But, if you do it in one of the two other ways, the JAR file will be included physically in your project. Please read this link https://stackoverflow.com/a/35369267/5475941 for more information. In this post I explained how to import your JAR file in Android studio and I explained all possible ways.

    In summary, if it is like this (local address), they are downloaded and these JAR files are physically in the project:

    But, if it is an internet address like this, they are remote libraries (bintray.com jcenter part) and they will be used remotely:

    I hope it helps.

    0 讨论(0)
  • 2020-11-21 04:53

    Open the build gradle module app file and add your dependency. If you download the library, just import and build as gradle.

    Otherwise add repositories in side gradle module app:

    repositories {
            maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
    }
    

    The first repositories will download the library for you.

    And compile the downloaded library:

     compile ('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
            transitive = true
        }
    

    If you are creating a library, you just need to import the project as import new module.

    0 讨论(0)
  • 2020-11-21 04:54

    If you have Android Studio .0.4.0, you can create a new folder in your build path, YourApp/libraries. Copy the JAR file. There in, right click on it and "Add As Library". Now you have a popup. Just select your directory and press OK, and that's it.

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