web-dev-qa-db-ja.com

Android BuildTypes vs. productflavorsエラー)

Android gradle 3.5.x "からGradle Plugin 4.10を卒業し、誤って誤って立ち往生しています。

これが私のbuild.gradleです

defaultConfig {

    applicationId "com.example.myapp
    targetSdkVersion targetSdkVersionVar
    multiDexEnabled true
}

flavorDimensions "version"

productFlavors {
    KitKat {
        sourceSets { "src/Android/KitKat" }
        dimension "version"
        minSdkVersion minSdkKitkat
        targetSdkVersion targetSdkKitkat
        versionNameSuffix "-KitKat"
    }
    nougat {
        sourceSets { "src/Android/nougat" }
        dimension "version"
        minSdkVersion minSdkNougat
        targetSdkVersion targetSdkVersionVar
        versionNameSuffix "-nougat"
    }
}


buildTypes {

    debug {
        multiDexKeepFile file('multidex-config.txt')
        multiDexKeepProguard file('multidex-config.pro')
        minifyEnabled false
        zipAlignEnabled true
        sourceSets {

            //main.Java.srcDirs += 'src/main/kotlin'
            main {
                Java.srcDirs = ['src/Android/default/Java/', 'src/common/Java/']
                jni.srcDirs = [] //disable ndk support
                manifest.srcFile 'src/Android/default/AndroidManifest.xml'
                resources.srcDirs = ['src/Android/default']
                aidl.srcDirs = ['src/Android/default']
                renderscript.srcDirs = ['src/Android/default']
                res.srcDirs = ['src/Android/default/res']
                assets.srcDirs = ['src/Android/default/assets']
            }
            test {
                Java.srcDirs = ['src/test/Java']
            }
            androidTest {
                Java.srcDirs = ['src/androidTest/Java']
            }
        }
    }
    release {
        multiDexKeepFile file('multidex-config.txt')
        multiDexKeepProguard file('multidex-config.pro')
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        zipAlignEnabled true
        sourceSets {

            main {
                Java.srcDirs = ['src/Android/default/Java/', 'src/common/Java/']
                jni.srcDirs = [] //disable ndk support
                manifest.srcFile 'src/Android/default/AndroidManifest.xml'
                resources.srcDirs = ['src/Android/default']
                aidl.srcDirs = ['src/Android/default']
                renderscript.srcDirs = ['src/Android/default']
                res.srcDirs = ['src/Android/default/res']
                assets.srcDirs = ['src/Android/default/assets']
            }
            test {
                Java.srcDirs = ['src/test/Java']
            }
            androidTest {
                Java.srcDirs = ['src/androidTest/Java']
            }
        }
    }
}
 _

私は次のエラーメッセージを受信しようとしています:

Could not determine the dependencies of task ':app:checkKitkatReleaseLibraries'.
> Could not resolve all task dependencies for configuration ':app:kitkatReleaseReverseMetadataValues'.
   > Could not resolve project :app.
     Required by:
         project :app
      > The consumer was configured to find a usage of 'Android-reverse-meta-data' of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'version' with value 'KitKat'. However we cannot choose between the following variants of project :app:
          - kitkatDebugAndroidTestCompile
          - kitkatDebugAndroidTestRuntime
          - kitkatDebugRuntime
          - kitkatDebugUnitTestCompile
          - kitkatDebugUnitTestRuntime
          - kitkatReleaseRuntime
          - kitkatReleaseUnitTestCompile
          - kitkatReleaseUnitTestRuntime
          - nougatDebugAndroidTestCompile
          - nougatDebugAndroidTestRuntime
          - nougatDebugRuntime
          - nougatDebugUnitTestCompile
          - nougatDebugUnitTestRuntime
          - nougatReleaseRuntime
          - nougatReleaseUnitTestCompile
          - nougatReleaseUnitTestRuntime
        All of them match the consumer attributes:
          - Variant 'kitkatDebugAndroidTestCompile' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'kitkatDebugAndroidTestRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'kitkatDebugRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'kitkatDebugUnitTestCompile' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'kitkatDebugUnitTestRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'kitkatReleaseRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'kitkatReleaseUnitTestCompile' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'kitkatReleaseUnitTestRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatDebugAndroidTestCompile' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatDebugAndroidTestRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatDebugRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatDebugUnitTestCompile' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatDebugUnitTestRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatReleaseRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatReleaseUnitTestCompile' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
          - Variant 'nougatReleaseUnitTestRuntime' capability myapp:app:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.Android.build.api.attributes.BuildTypeAttr (required 'release')
                  - Doesn't say anything about its usage (required a usage of 'Android-reverse-meta-data')
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :app' but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
                  - Doesn't say anything about version (required 'KitKat')
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'kitkatDebugApiElements' capability myapp:app:unspecified declares a component, as well as attribute 'version' with value 'KitKat':
              - Incompatible because this component declares an API of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a usage of 'Android-reverse-meta-data' of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release'
          - Variant 'kitkatDebugRuntimeElements' capability myapp:app:unspecified declares a component, as well as attribute 'version' with value 'KitKat':
              - Incompatible because this component declares a runtime of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a usage of 'Android-reverse-meta-data' of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release'
          - Variant 'kitkatReleaseApiElements' capability myapp:app:unspecified declares a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'version' with value 'KitKat':
              - Incompatible because this component declares an API of a component and the consumer needed a usage of 'Android-reverse-meta-data' of a component
          - Variant 'kitkatReleaseRuntimeElements' capability myapp:app:unspecified declares a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'version' with value 'KitKat':
              - Incompatible because this component declares a runtime of a component and the consumer needed a usage of 'Android-reverse-meta-data' of a component
          - Variant 'nougatDebugApiElements' capability myapp:app:unspecified:
              - Incompatible because this component declares an API of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'version' with value 'nougat' and the consumer needed a usage of 'Android-reverse-meta-data' of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'version' with value 'KitKat'
          - Variant 'nougatDebugRuntimeElements' capability myapp:app:unspecified:
              - Incompatible because this component declares a runtime of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'version' with value 'nougat' and the consumer needed a usage of 'Android-reverse-meta-data' of a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'version' with value 'KitKat'
          - Variant 'nougatReleaseApiElements' capability myapp:app:unspecified declares a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release':
              - Incompatible because this component declares an API of a component, as well as attribute 'version' with value 'nougat' and the consumer needed a usage of 'Android-reverse-meta-data' of a component, as well as attribute 'version' with value 'KitKat'
          - Variant 'nougatReleaseRuntimeElements' capability myapp:app:unspecified declares a component, as well as attribute 'com.Android.build.api.attributes.BuildTypeAttr' with value 'release':
              - Incompatible because this component declares a runtime of a component, as well as attribute 'version' with value 'nougat' and the consumer needed a usage of 'Android-reverse-meta-data' of a component, as well as attribute 'version' with value 'KitKat'
 _

その前に、私が卒業用ツールv 3.xを使っていたとき - それは本当にうまく機能していました。

考え、アイデア、ヒント、手がかり?

9
Barmaley

@ chrikiのコメントに続いて、最小限の再現性のある質問を定式化し、突然解決策を見つけました。魔法の声明は声明でした。

Android {
    ...
    dynamicFeatures = [":app"]
}
 _

この行をコメントしたときはいつでも、すべてがうまくいきます。

P.S.これはhateness放射線ログ/デバッグメッセージを卒業し、実際にロギング/メッセージングを参照してください。最後に、私は一週間近くで、解決策を見つけようとし、偶然に見出されています。

@chrikiが答えを投稿するなら、私は彼に恵みを報いるでしょう。

1
Barmaley