Question

I'm trying to import an Android project build on Eclipse into my Android Studio IDE. I'm following the steps to import properly the project with a build.gradle file but when I'm trying to compile, I get this weird error: Plugin with id 'android' not found. I have this version of Android Studio: Android Studio (Preview) 0.4.3. Here is my build.gradle:

 apply plugin: 'android'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':workspace:DesignDialogLibrary')
compile project(':workspace:HoloColorPickerLib')
compile project(':workspace:MbAdBleamSdkReaderLibrary')
compile project(':workspace:ViewPagerLibrary')
compile project(':workspace:PullToRefreshLibrary')
compile project(':workspace:SlidingMenuLib')
}

android {
compileSdkVersion 17
buildToolsVersion "18.0.1"

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    instrumentTest.setRoot('tests')

    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
 }
}
Was it helpful?

Solution

You're missing this block in your build.gradle file:

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

This block tells Gradle where to find the "android" plugin that you're missing.

It's standard in projects created in newer versions of Android Studio to put this in the build.gradle that's in your project's root directory and omit it from the one that's in your module's directory, so look there and see if looks like it's in order.

If you don't have that root-level build.gradle file and you've only got one directory and one build file, then add this block to that file. Be aware, however, that Android Studio currently has a few bugs that prevent the Project Structure dialog from working properly with projects in this single-module format, though I believe they'll otherwise build and run fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top