2017-05-22 4 views
134

Studio Canary 빌드로 업그레이드되었습니다. Telegram Messenger의 이전 프로젝트에서 다음과 같은 오류가 발생했습니다.Android Studio 3.0 Flavor 차원 문제

Error:All flavors must now belong to a named flavor dimension. The flavor 'armv7' is not assigned to a flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

어떻게해야합니까? 나는 이미 그 고리를 보았지만 무엇을 해야할지 이해할 수 없었다. 3 가지 변형을 지금, 릴리스, 디버그 및 foss 있습니다.

답변

307

당신이 정말로 메커니즘을 필요로하지 않는 경우, 그냥 무작위 맛의 차원을 지정

android { 
    ... 
    flavorDimensions "default" 
    ... 
} 

자세한 내용은 시도하고 조심스럽게 읽은 후 migration guide

+0

감사합니다. 나는 이미 "versionCode"차원을 가지고 있었고, 나는 그것을 사용했다. –

+2

flavorDimensions "versionCode를" productFlavors { 디버그 { 차원 "기본" versionName을 "1.0" } 출시 { 차원 "기본" versionName을 "1.0" } FOSS { 차원 "기본" versionName "1.0" } }이 오류가 발생했습니다 .ProductFlavor 이름은 BuildType 이름과 충돌 할 수 없습니다. 아무도 제발 도와 줄 수 없습니까? Kotlin과 3.0 베타 버전 Canary에서이 오류가 발생했습니다. –

+0

내 build.gradle 어디에서든지 맛을 사용하지 않으면 어떻게해야합니까? 2 buildTypes, 디버그 및 릴리스 있습니다. – mDroidd

46

을 확인, 내가 직접 해결했다. 해결책은 build.gradle에 다음 행을 추가하는 것입니다.

flavorDimensions "versionCode"

android { 
     compileSdkVersion 24 
     ..... 
     flavorDimensions "versionCode" 
} 
+2

어디에서 gradle에이 줄을 추가합니까?좀 더 많은 컨텍스트가 도움이 될 것입니다. –

+2

내부 build.gradle 파일, 안드로이드 {...} –

+0

android { compileSdkVersion 24 .... // 여기에 추가하십시오. –

9

당신이

android { 
compileSdkVersion 24 

... 
flavorDimensions "default" 
... 
} 

을이 줄을 사용해야하지만 TI 사용 치수를 원하는 경우 먼저 차원 이름을 선언하고 후이 이름을 사용한다 치수를 사용하지 않도록하려면 이 예제는 문서에서 나온 것입니다 :

android { 
... 
buildTypes { 
debug {...} 
release {...} 
} 

    // Specifies the flavor dimensions you want to use. The order in which you 
    // list each dimension determines its priority, from highest to lowest, 
    // when Gradle merges variant sources and configurations. You must assign 
    // each product flavor you configure to one of the flavor dimensions. 
    flavorDimensions "api", "mode" 

    productFlavors { 
    demo { 
    // Assigns this product flavor to the "mode" flavor dimension. 
    dimension "mode" 
    ... 
} 

full { 
    dimension "mode" 
    ... 
} 

// Configurations in the "api" product flavors override those in "mode" 
// flavors and the defaultConfig block. Gradle determines the priority 
// between flavor dimensions based on the order in which they appear next 
// to the flavorDimensions property above--the first dimension has a higher 
// priority than the second, and so on. 
minApi24 { 
    dimension "api" 
    minSdkVersion 24 
    // To ensure the target device receives the version of the app with 
    // the highest compatible API level, assign version codes in increasing 
    // value with API level. To learn more about assigning version codes to 
    // support app updates and uploading to Google Play, read Multiple APK Support 
    versionCode 30000 + android.defaultConfig.versionCode 
    versionNameSuffix "-minApi24" 
    ... 
} 

minApi23 { 
    dimension "api" 
    minSdkVersion 23 
    versionCode 20000 + android.defaultConfig.versionCode 
    versionNameSuffix "-minApi23" 
    ... 
} 

minApi21 { 
    dimension "api" 
    minSdkVersion 21 
    versionCode 10000 + android.defaultConfig.versionCode 
    versionNameSuffix "-minApi21" 
    ... 
    } 
    } 
} 
... 
4

나는 flavorDimens build.gradle에서 내 응용 프로그램에 대한 이온 (모듈 : 응용 프로그램)

flavorDimensions "tier" 

productFlavors { 
    production { 
     flavorDimensions "tier" 
     //manifestPlaceholders = [appName: APP_NAME] 
     //signingConfig signingConfigs.config 
    } 
    staging { 
     flavorDimensions "tier" 
     //manifestPlaceholders = [appName: APP_NAME_STAGING] 
     //applicationIdSuffix ".staging" 
     //versionNameSuffix "-staging" 
     //signingConfig signingConfigs.config 
    } 
} 
다음

Check this link for more info

// Specifies two flavor dimensions. 
flavorDimensions "tier", "minApi" 

productFlavors { 
    free { 
      // Assigns this product flavor to the "tier" flavor dimension. Specifying 
      // this property is optional if you are using only one dimension. 
      dimension "tier" 
      ... 
    } 

    paid { 
      dimension "tier" 
      ... 
    } 

    minApi23 { 
      dimension "minApi" 
      ... 
    } 

    minApi18 { 
      dimension "minApi" 
      ... 
    } 
} 
5

이 문제를 해결할 수 있습니다, 당신은 productFlavors의 이름으로 flavorDimension을 추가해야하고 차원을 정의해야 음, 자세한 내용은 아래의 예제를 참조하십시오. 여기를 참조하십시오.https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

flavorDimensions 'free','paid' //here defined dimensions 
productFlavors { 
    production { 
     dimension 'paid' //you just need to add this line 
     ... // your existing code 

    } 

    demo { 
     dimension 'free' //added here also 
     ... // your existing code 

    } 

    development { 
     dimension 'free' //add here too 
     ... // your existing code 

    } 
관련 문제