Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

build.gradle error in Android Studio

  • 07-01-2015 09:43PM
    #1
    Registered Users, Registered Users 2 Posts: 5,764 ✭✭✭


    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, Registered Users 2 Posts: 18,272 ✭✭✭✭Atomic Pineapple


    Do it compile OK if you remove the dependencies?


  • Registered Users, Registered Users 2 Posts: 931 ✭✭✭aperture_nuig


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


  • Registered Users, Registered Users 2 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, Registered Users 2 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