8

I have installed Android Studio (0.6.1) on OS X (10.9.3) and Gradle 1.1 using Brew (brew install gradle). However, I can't get my first Hello World! project... Please help me solve this issue

build.gradle:

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

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.1'
    defaultConfig {}
    productFlavors {}
}

dependencies {
}

Error message:

Error:(8, 0) Plugin with id 'android' not found.

Getting Build failed with an Exception Android Studio 0.4.3 and 0.4.4 post and Android Studio: Plugin with id 'android-library' not found post does not solves the problem...

Second post I linked returns this error message:

Error:The project is using an unsupported version of Gradle. Please use version 1.10. Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.) Fix Gradle wrapper and re-import project Gradle settings

Community
  • 1
  • 1
user927584
  • 395
  • 2
  • 6
  • 14

3 Answers3

16

It seems you have missed to add android gradle plugin dependency in dependencies block.

Replace the top buildScript section by this and sync your project with gradle

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

 apply plugin: 'android'

 android {
      compileSdkVersion 19
      buildToolsVersion '19.1.0'
      defaultConfig {
          applicationId 'YOUR_APP_PACKAGE'
          minSdkVersion 9
          targetSdkVersion 17
      }
      buildTypes {
          release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          }
      }
      productFlavors {   }
  }

  dependencies {

   }
Piyush Agarwal
  • 25,608
  • 8
  • 98
  • 111
  • 1
    Now I get this error `Error:The SDK Build Tools revision (19.0.3) is too low for project ':app'. Minimum required is 19.1.0` strange I followed [this guide](http://stackoverflow.com/questions/24093561/how-to-force-android-studio-0-6-0-to-use-sdk-build-tools-19-1-0) (second answer GUI one) On my GUI interface I don't have modules for some reason. (step 4) – user927584 Jun 19 '14 at 09:10
  • Please check the updated answer and match with your build.gradle file. – Piyush Agarwal Jun 19 '14 at 09:30
  • sometimes the buildscript declaration can be in a separate file which may be deleted hence the problem. – mugume david Sep 16 '15 at 15:34
3

build.gradle file inside my "app" folder: PATH: /home/work/ProjectName/app/build.gradle

android {
     compileSdkVersion 19
     buildToolsVersion '19.1.0'

defaultConfig {
    minSdkVersion 11
    targetSdkVersion 19
    versionCode 1
    versionName '1.0'
}


 dependencies {
  compile 'com.android.support:support-v4:18.0.0'
  compile 'com.android.support:appcompat-v7:+'

 }
}

build.gradle file outside my "app" folder: PATH: /home/work/ProjectName/build.gradle

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

allprojects {
repositories {
    mavenCentral()
}
}

Note after all these update synchronise your project with gradle file

sherin
  • 1,091
  • 2
  • 17
  • 27
2

Put below code in build.gradle file of main Application and sync it.

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

allprojects {
    repositories {
        mavenCentral()
    }
}

Credit to Ganesh Katikar

Community
  • 1
  • 1
Bao Le
  • 16,643
  • 9
  • 65
  • 68