简体   繁体   中英

How to add libraries to Android Studio?

I'm currently downloaded newest android studio 0.3.2. I've been trying to add libraries for almost 5 hours, and nothing.

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'. The errors in the IDE stop appearing, but when It 'compiles' it. It keeps telling me, that com.google.gson and other libraries don't exist.

How can I fix It? Or should I use Android studio?. Thank you very much.

EDIT

This is the build.gradle file, of the main project.

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

And this is the Gradle file of the 'Module' that gives problems:

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 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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