Android Studio:缺少添加为库选项

use*_*744 17 android android-studio

我已经开始使用Android Studio并遇到了问题.我似乎没有弄清楚为什么在我的项目中添加库时看不到Add as Library选项.
我为了添加库而执行的步骤:
*在app存储库中的libs文件夹中添加库. *右键单击以查看" 添加为库"选项.(看不到它!) *由于上面的步骤不起作用,我想到将库直接添加到libs文件夹中,即在Explorer中.失败!

因此,我无法继续我的项目.

PS:我已经删除了Eclipse,我不想安装再次进行设置.

build.gradle文件:

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')
     }
Run Code Online (Sandbox Code Playgroud)

谢谢.请帮忙!!!

Bla*_*elt 3

Android Studio是基于gradle的。如果您有一个 jar 文件作为项目的依赖项,请打开该build.gradle文件并添加到依赖项的部分

 compile files('libs/name_file.jar')
Run Code Online (Sandbox Code Playgroud)

如果您将库的源代码作为依赖项导入,则可以使用

compile project(':NameProject')
Run Code Online (Sandbox Code Playgroud)

来编译它。

您应该能够通过 UI 执行相同的操作。

右键单击您的项目并单击Open Module Settings,然后单击选项Dependencies卡。从那里您可以添加 jar 或库项目作为主项目的依赖项