title: Gradle build fails with error: Failed linking resources and AAPT2 error
body: <p>Every time I try to run the project or try to rebuild it,it throws error:failed linking resources. Please see screenshot:<img src="https://i.stack.imgur.com/wraF8.png" alt="Error Message"></p>
  
  <p>All the drawable are there still it is showing this.
  And all the R of my java files are in red color when hover it shows a message cannot resolve symbol 'R'
  See screenshot: <img src="https://i.stack.imgur.com/10yV9.png" alt="Java File Error"></p>
  
  <p>Error is coming in every java file I open.</p>
  
  <p>I tried Invalidating caches and cleaning project but nothing is working. Search everywhere but didn't find a solution.</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT: build.gradle(Module: app)</p>
  
  <pre><code>    // Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
  
      repositories {
          google()
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.1.2'
  
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p>build.gradle(Project:weMate)</p>
  
  <pre><code>    apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 26
      defaultConfig {
          applicationId "com.shivamtiwari.wemate"
          minSdkVersion 17
          targetSdkVersion 26
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation 'com.android.support:appcompat-v7:26.1.0'
      implementation 'com.android.support:design:26.1.0'
      implementation 'com.android.support.constraint:constraint-layout:1.0.2'
      implementation 'com.android.support:support-v4:26.1.0'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.1'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  }
  </code></pre>
  
  <p>After trying gradlew assembleDebug:</p>
  
  <pre><code>        Microsoft Windows [Version 10.0.16299.371]
  (c) 2017 Microsoft Corporation. All rights reserved.
  
  E:\MCA\AndroidProject\weMate&gt;gradlew assembleDebug
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_account.xml:27: AAPT: error: resource drawable/uploaddisplay (aka com.shivamtiwari.wemate:drawable/uploaddisplay) not fo
  und.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_car_pool.xml:9: AAPT: error: resource drawable/search_bar_bg (aka com.shivamtiwari.wemate:drawable/search_bar_bg) not fo
  und.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_car_pool.xml:21: AAPT: error: resource drawable/search_bar_bg (aka com.shivamtiwari.wemate:drawable/search_bar_bg) not f
  ound.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_car_pool.xml:33: AAPT: error: resource drawable/search_bar_bg (aka com.shivamtiwari.wemate:drawable/search_bar_bg) not f
  ound.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_car_pool.xml:51: AAPT: error: resource drawable/search_bar_bg (aka com.shivamtiwari.wemate:drawable/search_bar_bg) not f
  ound.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_car_pool.xml:64: AAPT: error: resource drawable/search_bar_bg (aka com.shivamtiwari.wemate:drawable/search_bar_bg) not f
  ound.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_car_pool_list.xml:8: AAPT: error: resource drawable/list_row_selector (aka com.shivamtiwari.wemate:drawable/list_row_sel
  ector) not found.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_helpdesk.xml:8: AAPT: error: resource drawable/search_bar_bg (aka com.shivamtiwari.wemate:drawable/search_bar_bg) not fo
  und.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\fragment_shop_list.xml:8: AAPT: error: resource drawable/list_row_selector (aka com.shivamtiwari.wemate:drawable/list_row_selecto
  r) not found.
  
  E:\MCA\AndroidProject\weMate\app\src\main\res\layout\nav_header_main.xml:2: AAPT: error: resource drawable/side_nav_bar (aka com.shivamtiwari.wemate:drawable/side_nav_bar) not found.
  
  error: failed linking file resources.
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':app:processDebugResources'.
  &gt; Failed to process resources, see aapt output above for details.
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Get more help at https://help.gradle.org
  
  BUILD FAILED in 4s
  13 actionable tasks: 1 executed, 12 up-to-date
  </code></pre>