title: How to add more build types in app than library
body: <p>Just like the example <a href="https://developer.android.com/studio/build/build-variants.html#build-types" rel="noreferrer">here</a> I am extending my build types to add staging:</p>
  
  <pre><code>android {
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
          debug {
              applicationIdSuffix '.debug'
          }
          staging {
              initWith release
              applicationIdSuffix '.staging'
          }
      }
  }
  </code></pre>
  
  <p>But I also have a dependency:</p>
  
  <pre><code>implementation project(':mylibrary')
  </code></pre>
  
  <p>Compilation fails because it doesn't know what to pair <code>staging</code> to in <code>:mylibrary</code>:</p>
  
  <pre><code>* What went wrong:
  Could not determine the dependencies of task ':app:compileStagingJavaWithJavac'.
  &gt; Could not resolve all task dependencies for configuration ':app:stagingCompileClasspath'.
     &gt; Could not resolve project :mylibrary.
       Required by:
           project :app
        &gt; Unable to find a matching configuration of project :mylibrary:
            - Configuration 'debugApiElements':
                - Required com.android.build.api.attributes.BuildTypeAttr 'staging' and found incompatible value 'debug'.
                - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
                - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
            - Configuration 'debugRuntimeElements':
                - Required com.android.build.api.attributes.BuildTypeAttr 'staging' and found incompatible value 'debug'.
                - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
                - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
            - Configuration 'releaseApiElements':
                - Required com.android.build.api.attributes.BuildTypeAttr 'staging' and found incompatible value 'release'.
                - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
                - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
            - Configuration 'releaseRuntimeElements':
                - Required com.android.build.api.attributes.BuildTypeAttr 'staging' and found incompatible value 'release'.
                - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
                - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
  </code></pre>
  
  <p>That's fair enough, but I cannot go through all of my libraries adding <code>staging</code> just to get a different application suffix.</p>
  
  <p>I tried:</p>
  
  <pre><code>debugImplementation project(path: ':mylibrary', configuration: 'debug')
  releaseImplementation project(path: ':mylibrary', configuration: 'release')
  stagingImplementation project(path: ':mylibrary', configuration: 'release')
  </code></pre>
  
  <p>But it fails:</p>
  
  <pre><code>* What went wrong:
  Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
  &gt; Could not resolve all task dependencies for configuration ':app:releaseCompileClasspath'.
     &gt; Could not resolve project :mylibrary.
       Required by:
           project :app
        &gt; Project :app declares a dependency from configuration 'releaseImplementation' to configuration 'release' which is not declared in the descriptor for project :mylibrary.
  
  debugImplementation project(path: ':mylibrary', configuration: 'default')
  releaseImplementation project(path: ':mylibrary', configuration: 'default')
  stagingImplementation project(path: ':mylibrary', configuration: 'default')
  </code></pre>
  
  <p>This works but every build has release build of library. I don't want that, I need debug to have debug version of library.</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/28081846/use-different-build-types-of-library-module-in-android-app-module-in-android-stu">this q</a>, but it's pre "<code>implementation</code>" and <code>publishNonDefault true</code> had no effect, same error as above.</p>
  
  <blockquote>
    <p>publishNonDefault is deprecated and has no effect anymore. All variants are now published.</p>
  </blockquote>
  
  <p>Gradlew version 4.6</p>