2

I am trying to open a ported Android application in Android studio and I keep getting the following error when I try to sync gradle: Error:(1, 0) Plugin with id 'android' not found.. I have seen a lot of posts regarding this issue, but none of the solutions has helped for me. This is my gradle file:

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:appcompat-v7:21.+'
    compile 'com.google.android.gms:play-services:6.5.+'
    compile 'com.getbase:floatingactionbutton:1.3.0'
}

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

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

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}
}

Please let me know if I am doing anything wrong or if you require additional information. Can you point me in the right direction? Thank you in advance.

EDIT

I have implemented the answer in that question and got the following results. Please reconsider

Error:Gradle version 1.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\Gerhardt\git\captis\gradle\wrapper\gradle-wrapper.properties to gradle-1.10-all.zip.

Please fix the project's Gradle settings.
<a href="openGradleSettings">Gradle settings</a>

So I pointed to version 2.2.1 instead and got this:

Error:Could not find com.android.tools.build:gradle:2.2.1.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
Required by:
    :captis:unspecified

I am at a loss of what to do. Please advise me?

Lunchbox
  • 1,538
  • 2
  • 16
  • 42
  • @Scott, I have exactly the same issue. Google is forcing us to migrate. That is ok. AS is pretty cool. But then you mark this as a dup.... But the dup link does not solve the problem. Surly this is a mistake? Any ideas Scott? Much appreciate your input. – Rup Dec 17 '14 at 21:10
  • It's best to be detailed when asking questions on SO that are similar to questions that have been asked before. Just saying that "none of the solutions has helped for me" often won't help answerers understand why they didn't work and how your case is different. – Scott Barta Dec 17 '14 at 21:45
  • arggg... good point! feeling silly right now. Thank you for the answer below. – Rup Dec 17 '14 at 22:26

1 Answers1

2

This is a duplicate of Error:(1, 0) Plugin with id 'android' not found, but blind copy-paste of its code is causing some problems.

That question advises you to put a buildscript block with repositories in your build script, but since the answer references a previous version of Android Studio, it has an older version of the Android Gradle plugin, and unfortunately Android Studio is giving you an unhelpful and incorrect error message when that happens. Do this, noting the newer version in the classpath statement. Actually, I assume you're running Studio 1.0 or later; if you're still running a beta version, you may need to hunt around to find the right version number:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}
Community
  • 1
  • 1
Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • Thank you for the answer! (and un-duplicate). Just need to add a lib that is causing errors then it should be fine – Lunchbox Dec 17 '14 at 22:36