title: Error:(66, 56) error: cannot find symbol variable M
body: <p>I have a sample app that is using library dependency via maven. I'm getting compilation errors like following:</p>
  
  <pre><code>Error:(66, 56) error: cannot find symbol variable M
  </code></pre>
  
  <p>Which actually is the following line in code</p>
  
  <pre><code>if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.M) {
          //something
      }
  </code></pre>
  
  <p>Here is the build.gradle for app module:</p>
  
  <pre><code> apply plugin: 'com.android.application'
  
      android {
       compileSdkVersion 27
  
      defaultConfig {
          applicationId "com.lokesh.videomoduletest"
          minSdkVersion 17
          targetSdkVersion 27
          versionCode 1
          versionName "1.0"
          vectorDrawables.useSupportLibrary = true
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
          debug {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      packagingOptions {
          exclude 'META-INF/rxjava.properties'
      }
      dataBinding {
          enabled = true
          version = '2.3.3'
      }
  
      lintOptions {
          abortOnError false
      }
  
      testOptions {
          unitTests.returnDefaultValues = true
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
       }
      }
  
      dependencies {
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation 'com.android.support:appcompat-v7:27.0.2'
      api "com.android.support:support-v4:27.0.2"
      implementation 'com.android.support.constraint:constraint-layout:1.0.2'
      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'
      implementation('com.libexp:a-gr:0.0.3@aar') {
          transitive = true
      }
      }
  </code></pre>
  
  <p>Here is the build.gradle for library module</p>
  
  <pre><code> android.testOptions.unitTests.all {
      // Configure whether failing tests should fail the build
      ignoreFailures false
  
      testLogging {
          events "passed", "skipped", "failed", "standardOut", "standardError"
      }
      jacoco {
          includeNoLocationClasses = true
      }
  
      jvmArgs '-noverify'
      }
  
      android {
      compileSdkVersion 27
  
      defaultConfig {
          minSdkVersion 17
          targetSdkVersion 27
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          debug {
              testCoverageEnabled true
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
          release {
              testCoverageEnabled false
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      lintOptions {
          abortOnError false
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  
      testOptions {
          unitTests.returnDefaultValues = true
      }
      }
  
       ext {
        supportLibraryVersion = '27.0.2'
        mockitoVersion = '2.8.47'
        timberVersion = '4.6.0'
        }
  
       dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
  
      testImplementation 'junit:junit:4.12'
      testImplementation "org.robolectric:robolectric:3.4"
      testImplementation "org.mockito:mockito-core:$mockitoVersion"
  
      androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
      androidTestImplementation "org.mockito:mockito-android:$mockitoVersion"
  
      implementation 'com.google.code.gson:gson:2.8.2'
      implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
  
      //RX
      implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
      implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
  
      //timber
      implementation "com.jakewharton.timber:timber:$timberVersion"
  
      // On-device logging
      implementation 'org.slf4j:slf4j-api:1.7.21'
      implementation 'com.github.tony19:logback-android-core:1.1.1-6'
      implementation('com.github.tony19:logback-android-classic:1.1.1-6') {
          // workaround issue #73
          exclude group: 'com.google.android', module: 'android'
      }
  
      //apache commons
      implementation 'org.apache.commons:commons-lang3:3.6'
      }
  </code></pre>
  
  <p>I found <a href="https://stackoverflow.com/questions/34623729/error-cannot-find-symbol-variable-lollipop">this</a>. But it didn't work for me as compileSdkVersion, targetSdkVersion is same in my case and also buildToolsVersion is optional in Android Studio 3.0</p>
  
  <p>Thanks.</p>