9

में एक मिलान कॉन्फ़िगरेशन खोजने में असमर्थ मुझे अपनी परियोजना को नवीनतम ग्रैडल 4.0 + एंड्रॉइड स्टूडियो 3 संस्करण में माइग्रेट करने में समस्याएं हैं, जो मुझे सभी प्रकार की त्रुटियां देती है। थोड़ा सा मैं इसे छोड़कर उन्हें बाहर निकालने में कामयाब रहा।एंड्रॉइड स्टूडियो 3 + ग्रैडल 4.0 + shrinkResources + libraryProject = प्रोजेक्ट

Could not resolve all dependencies for configuration ':app:forGoogleCoverageRuntimeClasspath'. 
    > Unable to find a matching configuration in project :mylibrary: 
     - Configuration 'debugApiElements': 
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'. 
      - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=debug}'. 
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required. 
      - Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'. 
      - Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided. 
     - Configuration 'debugRuntimeElements': 
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'. 
      - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=debug}'. 
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required. 
      - Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'. 
      - Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided. 
     - Configuration 'releaseApiElements': 
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'. 
      - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=release}'. 
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required. 
      - Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'. 
      - Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided. 
     - Configuration 'releaseRuntimeElements': 
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'. 
      - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=release}'. 
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required. 
      - Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'. 
      - Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided. 

आदेश समस्या जकड़ना करने के लिए:

  1. मैं एंड्रॉयड स्टूडियो परियोजना सहायक से एक न्यूनतम एप्लिकेशन परियोजना बना लिया है
  2. जो मैं तो मेरे एप्लिकेशन निर्भरता को जोड़ने के एक खाली पुस्तकालय मॉड्यूल जोड़ा ।
  3. एक flavorDimensions और 2 productFlavors
  4. जोड़ा 3 निर्माण प्रकार और एक निर्माण प्रकार एक और
  5. से विरासत विरासत में मिला निर्माण प्रकार सक्षम shrinkResources

अंतिम चरण में उल्लेख किया त्रुटि पैदा करता है करने देते हैं जोड़ा, जो इस प्रश्न के समान है: Gradle 4.0 Unable to find a matching configuration

क्या किसी को पता है कि इस समस्या का क्या समाधान है या इस समस्या का समाधान क्या है? मैं भी एक बग रिपोर्ट दर्ज करूंगा।

मेरे पूरा Gradle फ़ाइल:

apply plugin: 'com.android.application' 

apply plugin: 'kotlin-android' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "gradletest.test" 
     minSdkVersion 16 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 

    flavorDimensions "store" 

    productFlavors { 
     forAmazon { 
      dimension "store" 
     } 

     forGoogle { 
      dimension "store" 
     } 
    } 

    buildTypes { 

     debug { 
      debuggable true 
      minifyEnabled false 
     } 

     release { 
      minifyEnabled true 
      debuggable false 
      shrinkResources true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 

     coverage.initWith(buildTypes.debug) 
     coverage { 
      testCoverageEnabled true 
      minifyEnabled true 
      shrinkResources true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 


} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 

    implementation project(':mylibrary') 
} 
+0

बग रिपोर्ट निर्भरता संबंधित त्रुटियों जोड़कर तरह

Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve project :library. Open File Show Details

त्रुटि प्राप्त होगी आप इस त्रुटि को हल कर सकते हैं /issuetracker.google.com/issues/62170415 स्टार करने के लिए स्वतंत्र महसूस करें। अभी के लिए यह मेरे निर्माण प्रकार – JimmyVanBraun

उत्तर

6

संभावित समाधान, buildTypes लापता सभी मॉड्यूल में बना है, लेकिन जब गूगल planed इसके लिए एक sollution बनाने यह पागलपन खिलवाड़ कोड है। अधिक जानकारी: https://issuetracker.google.com/issues/62170415 मेरे रूप में (लेकिन मॉडरेटर द्वारा हटाई गई) और आप उल्लेख करते हैं।

लेकिन वहाँ पीछे नहीं है (एक ही है, लेकिन बहुत क्लीनर) समाधान: अपने शीर्ष परियोजना के लिए build.gradle

subprojects { 
    afterEvaluate {project -> 
     if (project.hasProperty("android")) { 
      android { 
       buildTypes { 
        YOUR_MISSING_BUILD_TYPES { 
         BUILD_TYPE_PARAMS_OR_EMPTY 
        } 
       } 
      } 
     } 
    } 
} 

संपादित जोड़ें: 2017-07-12

यह अंततः classpath 'com.android.tools.build:gradle:3.0.0-alpha6' में निश्चित होती है। आप नए डीएसएल उपयोग कर सकते हैं: https://issuetracker.google.com/issues/62241369

android { 
    buildTypeMatching 'staging', 'debug' 
    productFlavorMatching 'color', 'blue', 'cyan' 
} 

मत निर्माण परियोजना से पहले ऊपर वैकल्पिक हल निकालने के लिए भूल गया!

संपादित करें: 2017-07-18

वहाँ आधिकारिक दस्तावेज है: https://issuetracker.google.com/issues/62241369

इस त्रुटि को हल करने के लिए आप जो से प्रकार का निर्माण निर्दिष्ट करने की आवश्यकता "MyLibrary" एंड्रॉयड प्लगइन ऐप के "स्टेजिंग" बिल्ड प्रकार से मेल खाना चाहिए। आप ऐप के निर्माण में buildTypeMatching प्रॉपर्टी के साथ ऐसा कर सकते हैं।Gradle फ़ाइल, जिन्हें आप नीचे:

// Add the following to the consumer's build.gradle file. 
android { 
    ... 
    // Tells the Android plugin to use a library's 'debug' build type 
    // when a 'staging' build type is not available. You can include 
    // additional build types, and the plugin matches 'staging' to the 
    // first build type it finds from the one's you specify. That is, 
    // if 'mylibrary' doesn't include a 'debug' build type either, the 
    // plugin matches 'staging' with the producer's 'release' build type. 
    buildTypeMatching 'staging', 'debug', 'release' 
} 

संपादित करें: 2017-09-06

buildTypeMatching से बीटा के रूप में 4.
अब matchingFallbacks का उपयोग हटा दिया गया है।
देखें: https://stackoverflow.com/a/46038946/4594990

+0

से संकीर्ण स्रोतों को हटाने में मेरी सहायता करता है मेरी प्रोजेक्ट में, ऐप मॉड्यूल और lib मॉड्यूल में बिल्ड प्रकार 'डीबग' और 'रिलीज़' है। ऐप build.gradle में buildTypeMatching 'डीबग', 'रिलीज' डालने का प्रयास किया। यह अभी भी वही त्रुटि फेंकता है https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#buildTypeMatching – DroidLearner

+0

ऐप और लाइब्रेरी https: // gist के लिए मेरा निर्माण प्रकार यहां है .github.com/अज्ञात/1dda4a85d4d3c021a8fc07251901f9f2 – DroidLearner

+1

buildTypeMatching को हटा दिया गया है। https://stackoverflow.com/a/46038946/4594990 – vigilancer

0

Gradle 4.0 Unable to find a matching configuration

की संभावित डुप्लिकेट सुनिश्चित करें कि आप अपने मॉड्यूल के सभी में निर्माण विन्यास (buildTypes) की सही संख्या किया हुआ है।

मेरी पूर्व -3.0 सेटअप में, मैं अपने com.android.library मॉड्यूल के सभी में केवल डिबग {} और रिहाई {} रहा था। मैंने ऐप मॉड्यूल के समान एक और कॉन्फ़िगरेशन जोड़ा। यह मेरे लिए ठीक बनाता है।

+0

कैनरी 4 और 6 में काम करने का आपका तरीका, कैनरी 7 और कैनरी 8 में, यह अभी भी एक त्रुटि फेंकता है – DroidLearner

+0

ऐप और लाइब्रेरी https के लिए मेरा निर्माण प्रकार यहां है: //gist.github.com/anonymous/1dda4a85d4d3c021a8fc07251901f9f2 – DroidLearner

3

यदि आपके ऐप में एक बिल्ड प्रकार शामिल है जो लाइब्रेरी निर्भरता नहीं करता है।

उदाहरण के लिए, आपके ऐप में "स्टेजिंग" बिल्ड प्रकार शामिल है, लेकिन एक निर्भरता में केवल "डीबग" और "रिलीज" बिल्ड प्रकार शामिल है। https::/

आप

buildTypes { 
     staging { 
      proguardFile getDefaultDexGuardFile('dexguard-release.pro') 
      proguardFile 'dexguard-rules.pro' 
      matchingFallbacks = ['debug', 'release'] //add this line 
     } 
    } 

हल निर्माण के तहत मिलान official docs

संबंधित मुद्दे