简体   繁体   English

如何将库添加到Android Studio?

[英]How to add libraries to Android Studio?

I'm currently downloaded newest android studio 0.3.2. 我目前下载的是最新的Android Studio 0.3.2。 I've been trying to add libraries for almost 5 hours, and nothing. 我已经尝试添加库了将近5个小时,什么也没有。

I've pressed F4 in the 'Module' where the libraries should go, added the libraries, also in the project structure added the dependencies, and also in build.gradle of the 'Module'. 我在要放置库的“模块”中按了F4,添加了库,还在项目结构中添加了依赖项,还在“模块”的build.gradle中添加了F4。 The errors in the IDE stop appearing, but when It 'compiles' it. IDE中的错误停止出现,但是在“编译”它时出现。 It keeps telling me, that com.google.gson and other libraries don't exist. 它不断告诉我,com.google.gson和其他库不存在。

How can I fix It? 我该如何解决? Or should I use Android studio?. 还是应该使用Android Studio? Thank you very much. 非常感谢你。

EDIT 编辑

This is the build.gradle file, of the main project. 这是主项目的build.gradle文件。

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}

And this is the Gradle file of the 'Module' that gives problems: 这是产生问题的“模块”的Gradle文件:

apply plugin: 'java'

sourceSets {
    main.java.srcDirs = ['src']
    main.resources.srcDirs = ['src']
    test.java.srcDirs = ['tests/java']
    test.resources.srcDirs = ['tests/resources']
}

Here is an example for the Google Analytics library and the Gson library : 这是Google Analytics(分析)库Gson库的示例:

dependencies {
    ...
    compile 'com.google.code.gson:gson:2.2.4'
    compile files('libs/libGoogleAnalyticsServices.jar')
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM