2017-05-22 40 views
134

Zaktualizowany do wersji Studio Canary. Mój poprzedni projekt Telegram Messenger podaje następujący błąd.Android Studio 3.0 Format wymiaru smaków

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

Co należy zrobić? Widziałem już ten link, ale nie mogłem zrozumieć, co robić. Mam teraz 3 warianty kompilacji, wydania, debugowania i fossowania.

Odpowiedz

307

Jeśli naprawdę nie potrzebują mechanizmu, wystarczy określić losowy wymiar smakowy:

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

Aby uzyskać więcej informacji, sprawdź migration guide

+0

Dzięki. Miałem już wymiar "versionCode", użyłem tego. –

+2

flavorDimensions "versionCode" productFlavors { debugowania { wymiar "domyślny" versionName "1.0" } uwalnianiu { wymiar "domyślny" versionName "1.0" } FOSS { wymiar "domyślny" versionName "1.0" } } Mam ten błąd .. Nazwy produktuProductFlavor nie mogą kolidować z nazwami BuildType. Czy możesz proszę, żeby ktoś mi pomógł. Mam ten błąd wersji 3.0 beta kanarka z Kotlinem. –

+0

Co mam zrobić, jeśli nie używam smaków w dowolnym miejscu w moim build.gradle? Mam 2 typy buildTypes, debugowanie i wydanie. – mDroidd

46

Po wypróbowaniu i uważnie czytać, I rozwiązać go samodzielnie. Rozwiązaniem jest dodanie następującego wiersza w pliku build.gradle.

flavorDimensions "versionCode"

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

gdzie w gradle można dodać tę linię?Pomocne byłoby trochę więcej kontekstu –

+2

Wewnątrz pliku build.gradle, w Androidzie {...} –

+0

android { compileSdkVersion 24 .... // dodaj tutaj} –

9

Jeśli chcesz, aby nie używać wymiarów należy użyć tej linii

android { 
compileSdkVersion 24 

... 
flavorDimensions "default" 
... 
} 

ale jeśli chcesz wymiary użytku ti należy zadeklarować swoją nazwę wymiaru, a następnie użyć tej nazwy po TEN przykład pochodzi z dokumentacji:

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

Użyłem flavorDimens Jony dla mojej aplikacji w build.gradle (moduł: app)

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

Tutaj można rozwiązać ten problem, należy dodać flavorDimension nazwą productFlavors i trzeba zdefiniować jako wymiar cóż, zobacz poniższy przykład i więcej informacji można znaleźć tutaj: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 

    } 
Powiązane problemy