title: Unable to fix "Plugin with id 'com.android.application' not found"
body: <blockquote>
    <p>Plugin with id 'com.android.application' not found</p>
  </blockquote>
  
  <p>That's the error I get each time I sync the project.</p>
  
  <p><strong>Project level build.gradle</strong></p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.2.3'
          classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
          classpath 'io.realm:realm-gradle-plugin:2.3.1'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          jcenter()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p><strong>app Level gradle file</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'android-apt'
  apply plugin: 'realm-android'
  
  android {
      compileSdkVersion 25
      buildToolsVersion '25.0.2'
      defaultConfig {
          applicationId "com.example.appname"
          minSdkVersion 16
          targetSdkVersion 25
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
  //    packagingOptions {
  //        exclude 'META-INF/INDEX.LIST'
  //        exclude 'META-INF/DEPENDENCIES'
  //        exclude 'META-INF/LICENSE'
  //        exclude 'META-INF/spring.handlers'
  //        exclude 'META-INF/spring.schemas'
  //        exclude 'META-INF/cxf/bus-extensions.txt'
  //    }
  
      android {
          lintOptions {
              abortOnError false
          }
      }
  
  }
  
  dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      compile 'com.android.support:appcompat-v7:25.1.1'
      compile 'com.android.support:design:25.1.1'
      compile 'com.android.support:support-v4:25.1.1'
      compile 'com.android.support:cardview-v7:25.1.1'
      compile 'com.android.support:recyclerview-v7:25.1.1'
      compile 'com.jakewharton:butterknife:8.5.1'
      compile 'jp.wasabeef:recyclerview-animators:2.2.4'
      compile 'io.reactivex:rxandroid:1.2.1'
      compile 'commons-io:commons-io:2.5'
      compile 'io.reactivex:rxjava:1.2.4'
      compile 'com.squareup.picasso:picasso:2.5.2'
      compile 'io.realm:android-adapters:1.4.1'
      compile 'com.squareup.okhttp:okhttp:2.7.5'
      testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
      testCompile 'junit:junit:4.12'
      apt 'com.jakewharton:butterknife-compiler:8.5.1'
      debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
      releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
      compile project(':poishadow-all')
  }
  </code></pre>
  
  <p><strong>Effects made to fix it</strong></p>
  
  <ol>
  <li><p>Tried <a href="https://stackoverflow.com/a/25232725/6181476">this popular answer</a></p></li>
  <li><p>Tried File > Invalidate Caches / Restart</p></li>
  <li><p>Copied another projects app and project levels build.gradle files</p></li>
  </ol>
  
  <p><strong>Observations</strong></p>
  
  <p>If I remove <code>apply plugin: 'com.android.application</code> and sync the error becomes </p>
  
  <blockquote>
    <p>Plugin with id 'android-apt' not found</p>
  </blockquote>
  
  <p>and If I also remove <code>Plugin with id 'android-apt' not found</code> the error becomes </p>
  
  <blockquote>
    <p>'Plugin with id realm-android' not found.</p>
  </blockquote>
  
  <hr>
  
  <p><strong>EDIT</strong>
  I ran <code>./gradlew build --stacktrace</code> and I got this:</p>
  
  <pre><code>* Exception is:
  org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'app'.
          at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
          at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176)
          at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
          at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181)
          at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
          at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
          at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
          at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:70)
          at org.gradle.configuration.project.LifecycleProjectEvaluator.access$000(LifecycleProjectEvaluator.java:33)
          at org.gradle.configuration.project.LifecycleProjectEvaluator$1.execute(LifecycleProjectEvaluator.java:53)
          at org.gradle.configuration.project.LifecycleProjectEvaluator$1.execute(LifecycleProjectEvaluator.java:50)
          at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
          at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:50)
          at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:628)
          at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:129)
          at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
          at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:60)
          at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
          at org.gradle.initialization.DefaultGradleLauncher$1.execute(DefaultGradleLauncher.java:161)
          at org.gradle.initialization.DefaultGradleLauncher$1.execute(DefaultGradleLauncher.java:158)
          at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
          at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:158)
          at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
          at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
          at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
          at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
          at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
          at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
          at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
          at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
          at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
          at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
          at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
          at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
          at org.gradle.util.Swapper.swap(Swapper.java:38)
          at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
          at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
          at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
          at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
          at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
          at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
          at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
          at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
  Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'com.android.application' not found.
          at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:110)
          at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
          at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
          at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
          at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
          at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:44)
          at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
          at org.gradle.api.Script$apply.callCurrent(Unknown Source)
          at build_adp866r1t6j1hlthh3am8fjsj.run(/home/ozuf/Android/Projects/appname/app/build.gradle:1)
          at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
          ... 62 more
  
  
  BUILD FAILED
  
  Total time: 2.29 secs
  </code></pre>