Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

build.gradle error in Android Studio

Options
  • 07-01-2015 10:43pm
    #1
    Registered Users Posts: 5,557 ✭✭✭


    Getting the below error when i clean project

    Error:(9) A problem occurred evaluating root project 'MyApplication'.
    > Could not find method compile() for arguments [file collection] on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@e66da7c.


    Is there any obvious problem with build.gradle - am pretty new to the syntax.

    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
    applicationId "com.example.erayfra.myapplication"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
    }
    buildTypes {
    release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }
    }

    dependencies {
    compile fileTree(include: , dir: 'libs')
    compile('com.android.support:appcompat-v7:21.0.3')
    compile files('libs/mysql-connector-java-3.1.14-bin.jar')
    compile files('libs/gson-2.3.1.jar')
    compile('com.android.support:appcompat-v7:+')

    }


Comments

  • Registered Users Posts: 18,272 ✭✭✭✭Atomic Pineapple


    Do it compile OK if you remove the dependencies?


  • Registered Users Posts: 930 ✭✭✭aperture_nuig


    Not near my dev PC, but is the first line not supposed to be:
    apply plugin 'android'
    ?


  • Registered Users Posts: 18,272 ✭✭✭✭Atomic Pineapple


    Not near my dev PC, but is the first line not supposed to be:
    apply plugin 'android'
    ?

    I don't think so, here is an example of a working Gradle file from one of my projects:
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 21
        buildToolsVersion "20.0.0"
    
        defaultConfig {
            applicationId "com.ex.mine"
            minSdkVersion 20
            targetSdkVersion 21
            versionCode 3
            versionName "0.3"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile project(':common')
        compile 'com.google.android.gms:play-services:6.1.71'
        compile 'com.android.support:appcompat-v7:21.0.0'
        compile 'com.android.support:cardview-v7:21.0.0'
        compile 'com.android.support:recyclerview-v7:21.0.0'
        compile 'com.android.support:palette-v7:21.0.0'
        compile 'com.mcxiaoke.volley:library:1.0.9'
        compile 'com.google.code.gson:gson:2.2.4'
        compile 'com.squareup.okhttp:okhttp:2.0.0'
        compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
    }
    


  • Registered Users Posts: 50 ✭✭EamonnDunne


    This stackoverflow question appears to address the same problem stackoverflow.com/questions/18735923/importing-jar-libraries-into-android-studio , its a little old but I think it should help.


Advertisement