title: Cannot create variant 'android-lint' after configuration
body: <p>I am updating my project's Gradle plugin from 2.1.2 to 3.1.0 but the gradle starts throwing error while build :</p>
  
  <blockquote>
    <p>Cannot create variant 'android-lint' after configuration
    ':app:debugRuntimeElements' has been resolved</p>
  </blockquote>
  
  <p>project level gradle :</p>
  
  <pre><code> // Top-level build file 
   buildscript {
  repositories {
      jcenter()
      mavenCentral()
      maven { url 'https://maven.fabric.io/public' }
      maven {
          url 'https://maven.google.com/'
          name 'Google'
      }
      google()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle:3.1.1'
      classpath 'org.ajoberstar:gradle-git:0.6.3'
      //noinspection GradleDynamicVersion
      classpath 'io.fabric.tools:gradle:1.+'
      classpath 'me.tatarka:gradle-retrolambda:3.2.5'
      classpath 'com.google.gms:google-services:3.0.0'
  }
  }
  
   // Used to disable preDex, will speed up clean build but slow down incremental builds.
    project.ext.preDexLibs = !project.hasProperty('disablePreDex')
  
   subprojects {
  project.plugins.whenPluginAdded { plugin -&gt;
      if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
          project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
      } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
          project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
      }
  }
  }
  
  allprojects {
  repositories {
      jcenter()
   }
   }
  </code></pre>
  
  <p>library level gradle : </p>
  
  <pre><code> apply plugin: 'com.android.library'
  
   setVersion '1.2'
  
  repositories {
  mavenCentral()
  maven {
      url 'https://maven.google.com/'
      name 'Google'
  }
  }
  
  configurations {
  classpaths
  }
  
  def sharedManifest = manifest {
  attributes('Specification-Title': 'My App',
             'Specification-Version': '2.1',
             'Specification-Vendor': 'App Vendor',
             'Implementation-Title': 'App',
             'Implementation-Version': '2.1',
             'Implementation-Vendor': 'App Vendor')
   }
  
  android {
  compileSdkVersion 27
  buildToolsVersion "27.0.3"
  
  defaultConfig {
      minSdkVersion 15
      targetSdkVersion 27
      consumerProguardFile file("proguard-project.txt")
  }
  
  buildTypes {
      debug {
          testCoverageEnabled true
      }
  }
  
  // work-around for duplicate files during packaging of APK
  packagingOptions {
      exclude 'META-INF/LICENSE'
      exclude 'META-INF/NOTICE'
  }
  
  compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
  }
  }
  
  dependencies {
  implementation project(':exclude-doclet')
  implementation 'com.android.support:support-annotations:27.0.2'
  implementation 'com.android.support:support-v4:27.0.2'
  implementation 'commons-io:commons-io:2.4'
  implementation 'com.squareup.retrofit2:retrofit:2.1.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
  implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
  implementation 'com.google.code.gson:gson:2.4'
  implementation 'io.reactivex:rxandroid:1.2.1'
  implementation 'io.reactivex:rxjava:1.1.7'
  classpaths files(new File(System.getenv("ANDROID_HOME") + "/platforms/android-${Integer.parseInt(rootProject.ANDROID_BUILD_SDK_VERSION)}/android.jar"),
          new File(System.getenv("ANDROID_HOME") + "/extras/android/support/v4/android-support-v4.jar"))
  testImplementation 'junit:junit:4.12'
  testImplementation 'org.mockito:mockito-core:1.10.19'
  androidTestImplementation 'junit:junit:4.12'
  androidTestImplementation 'org.mockito:mockito-core:1.10.19'
  }
  
  android.libraryVariants.all { variant -&gt;
  String name = variant.buildType.name
  task("generate${name.capitalize()}Javadoc", type: Javadoc) {
      dependsOn variant.javaCompiler
      description "Generates Javadoc for $project.name."
  
      title "App $project.version"
      source = variant.javaCompiler.source
      classpath += project.files(variant.javaCompiler.classpath.files, android.getBootClasspath())
      List&lt;File&gt; pathList = new ArrayList&lt;File&gt;()
      pathList.add(new File(project(':exclude-doclet').libsDir,
                            "ExcludeDoclet-${project(':exclude-doclet').version}.jar"))
      options {
          doclet = "ExcludeDoclet"
          docletpath = pathList
          encoding = "UTF-8"
          classpath = configurations.classpaths.files.asType(List)
          linksOffline "http://developer.android.com/reference", "${android.sdkDirectory}/docs/reference"
          links "http://docs.oracle.com/javase/7/docs/api/",
                "http://square.github.io/retrofit/2.x/retrofit/",
                "http://square.github.io/okhttp/2.x/okhttp/",
                "http://reactivex.io/RxJava/javadoc/"
          memberLevel = JavadocMemberLevel.PUBLIC
          header = "AppKit"
      }
      exclude '**/BuildConfig.java'
      exclude '**/R.java'
      failOnError true
  
      doLast {
          copy {
              from 'src/javadoc/assets/'
              into destinationDir.path + '/assets/'
          }
      }
  }
  
  task("assemble${name.capitalize()}JavadocJar", type: Jar) {
      dependsOn "generate${name.capitalize()}Javadoc"
      description "Assembles Jar contaning Javadoc for $project.name."
      from project.tasks.getByName("generate${name.capitalize()}Javadoc").destinationDir
      classifier = 'javadoc'
      manifest {
          from sharedManifest
      }
  }
  
  task("assemble${name.capitalize()}Jar", type: Jar) {
      dependsOn variant.javaCompiler
      description "Assembles Jar contaning $project.name."
      from variant.javaCompiler.destinationDir
      manifest {
          from sharedManifest
      }
  }
  
  artifacts {
      archives project.tasks.getByName("assemble${name.capitalize()}Jar")
      archives project.tasks.getByName("assemble${name.capitalize()}JavadocJar")
  }
  }
  </code></pre>
  
  <p>I am stuck with this issue and don't find any solution. Can anyone help me out.</p>