Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: Add as Library option missing

I've started using Android Studio and have encountered a problem. I don't seem to figure out why I can't see the Add as Library option when I add a library in my project.
The steps I performed in order to add library:
* Add library in the libs folder present in the app repository.
* Right-click to see for option Add as Library. (Cannot see it!)
* Since the above step didn't work I thought of adding the library directly in the libs folder i.e. in the Explorer. FAILED!

Because of this I'm unable to proceed with my project.

P.S.: I've removed Eclipse and I don't wanna install do the setup all over again.

build.gradlefile:

apply plugin: 'com.android.application'

android {
          compileSdkVersion 21
          buildToolsVersion "21.1.2"

          defaultConfig {
                         applicationId "com.example.team1cloud.cloudapp"
                         minSdkVersion 15
                         targetSdkVersion 21
                         versionCode 1
                         versionName "1.0"
                        }
buildTypes {
    release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
          }
        }
dependencies
      {
       compile fileTree(dir: 'libs', include: ['*.jar'])
       compile 'com.android.support:appcompat-v7:21.0.3'
       compile 'com.google.apis:google-api-services-drive:v2-rev161-1.19.1'
       compile files('libs/commons-logging-1.1.1.jar')
       compile files('libs/google-api-client-1.18.0-rc.jar')
       compile files('libs/google-api-client-android-1.18.0-rc.jar')
       compile files('libs/google-api-client-appengine-1.18.0-rc.jar')
       compile files('libs/google-api-client-gson-1.18.0-rc.jar')
       compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
       compile files('libs/google-api-client-java6-1.18.0-rc.jar')
       compile files('libs/google-api-client-protobuf-1.18.0-rc.jar')
       compile files('libs/google-api-client-servlet-1.18.0-rc.jar')
       compile files('libs/google-api-client-xml-1.18.0-rc.jar')
       compile files('libs/google-http-client-1.18.0-rc.jar')
       compile files('libs/google-http-client-android-1.18.0-rc.jar')
       compile files('libs/google-http-client-appengine-1.18.0-rc.jar')
       compile files('libs/google-oauth-client-java6-1.18.0-rc.jar')
       compile files('libs/google-oauth-client-jetty-1.18.0-rc.jar')
       compile files('libs/google-oauth-client-servlet-1.18.0-rc.jar')
       compile files('libs/google-play-services.jar')
       compile files('libs/gson-2.1.jar')
       compile files('libs/httpclient-4.0.1.jar')
       compile files('libs/httpcore-4.0.1.jar')
       compile files('libs/jackson-core-2.1.3.jar')
       compile files('libs/jackson-core-asl-1.9.11.jar')
       compile files('libs/jdo2-api-2.3-eb.jar')
       compile files('libs/jetty-6.1.26.jar')
       compile files('libs/jetty-util-6.1.26.jar')
       compile files('C:/Users/sjeet/AndroidStudioProjects/CloudApp/gradle/wrapper/gradle-wrapper.jar')
     }

Thanks. Please help!!!

like image 635
user2607744 Avatar asked Mar 11 '15 08:03

user2607744


People also ask

How do I add a library project to Android Studio?

Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Library Dependency in the dropdown. In the Add Library Dependency dialog, use the search box to find the library to add.

Where are libraries Android studio?

The android default libraries like appcompact, design support libraries are stored in your folder where you have installed the SDK, precisely <SDK FOLDER>/extras/android/m2repository/com/android . The 3rd party libraries are stored in . gradle/caches/modules-2/files-2.1 folder.


1 Answers

Android Studio is gradle based. If you have a jar file as dependency for your project, open the build.gradle file and add in the dependency's section

 compile files('libs/name_file.jar')

if you imported the source code of the library as dependency you can use

compile project(':NameProject')

to compile it.

You should be able to do the same thing trough the UI.

Right click on your project and click on Open Module Settings, and then click on the Dependencies tab. From there you can add jar or library project as dependency for your main project

like image 200
Blackbelt Avatar answered Oct 14 '22 14:10

Blackbelt