title: kotlinx.android.synthetic not found when running gradle
body: <p>I'm using Kotlin Android Extensions.
  My project gradle:</p>
  
  <pre><code>buildscript {
      ext.kotlin_version = '1.2.41'
  dependencies {
          classpath 'com.android.tools.build:gradle:3.1.2'
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  ...
  </code></pre>
  
  <p>My app gradle:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-android-extensions'
  apply plugin: 'io.fabric'
  apply plugin: 'kotlin-kapt'
  apply plugin: 'jacoco-android'
  apply plugin: "kotlin-allopen"
  ...
  </code></pre>
  
  <p>Gradle version 4.6
  Android Studio 3.1.2
  Build #AI-173.4720617, built on April 14, 2018
  JRE: 1.8.0_152-release-1024-b01 x86_64
  JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  Mac OS X 10.13.4</p>
  
  <p>When running everything through the IDE everything works, but when running through the console <code>gradle -p ~/source/android-app assembleDebug</code> suddenly the IDE marks any <code>import kotlinx.android.synthetic.main...</code> as not being used and any views in code are marked as not found. <strong>The build succeeds</strong></p>
  
  <p>It used to work, one of the versions that I upgraded (Android studio, gradle, Kotlin plugin)  broke it. Any ideas on what to do next ?</p>
  
  <p>Console output:
  <code>
  19:46 $ gradle -p ~/source/android-app assembleDebug --console plain
  WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
  It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
  registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
  registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
  registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
  registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
  registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
  :app:preBuild UP-TO-DATE
  :app:preDebugBuild UP-TO-DATE
  :app:compileDebugAidl UP-TO-DATE
  :app:compileDebugRenderscript UP-TO-DATE
  :app:checkDebugManifest UP-TO-DATE
  :app:generateDebugBuildConfig
  :app:mainApkListPersistenceDebug
  :app:generateDebugResValues UP-TO-DATE
  :app:generateDebugResources UP-TO-DATE
  :app:processDebugGoogleServices
  Parsing json file: /Users/efimerdler-kravitz/source/android-app/app/google-services.json
  :app:mergeDebugResources UP-TO-DATE
  :app:createDebugCompatibleScreenManifests
  :app:processDebugManifest
  :app:splitsDiscoveryTaskDebug UP-TO-DATE
  :app:processDebugResources
  :app:kaptGenerateStubsDebugKotlin
  :app:kaptDebugKotlin
  :app:compileDebugKotlin
  :app:prepareLintJar UP-TO-DATE
  :app:generateDebugSources
  :app:javaPreCompileDebug UP-TO-DATE
  :app:compileDebugJavaWithJavac
  :app:compileDebugNdk NO-SOURCE
  :app:compileDebugSources
  :app:mergeDebugShaders UP-TO-DATE
  :app:compileDebugShaders UP-TO-DATE
  :app:generateDebugAssets UP-TO-DATE
  :app:mergeDebugAssets UP-TO-DATE
  :app:transformClassesWithDexBuilderForDebug
  :app:transformDexArchiveWithExternalLibsDexMergerForDebug
  :app:transformDexArchiveWithDexMergerForDebug
  :app:mergeDebugJniLibFolders UP-TO-DATE
  :app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
  :app:processDebugJavaRes NO-SOURCE
  :app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
  :app:validateSigningDebug UP-TO-DATE
  :app:packageDebug
  :app:assembleDebug
  </code></p>