3

は、Android 5とし、上記のデバイスのために構築します。マルチデックスをコントロールし、製品のフレーバーからマイナー化する方法は?私はデバッグを向上させるために、次のフレーバーを使用しています

productFlavors { 
    // Define separate dev and prod product flavors. 
    dev { 
     // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin 
     // to pre-dex each module and produce an APK that can be tested on 
     // Android Lollipop without time consuming dex merging processes. 
     minSdkVersion 21 
    } 
    prod { 
     // The actual minSdkVersion for the application. 
     minSdkVersion 16 
    } 
    } 

をただしていない、私のすべてのデバイスは、API 21+下で実行され、したがって、私はmultiDexとにより縮小を制御したいです。例えば:

productFlavors { 
    dev { 
     minSdkVersion 21 
     multiDexEnabled false 
     minifyEnabled false 
    } 
    prod { 
     minSdkVersion 16 
     multiDexEnabled true 
     minifyEnabled true 
    } 
    } 

しかし、それはだが私を与える:

Error:(44, 0) Could not find method minifyEnabled() for arguments [false] on ProductFlavor_Decorated 

は、どのように私は一緒に、これらの特性を組み合わせることができますか?

答えて

2

minifyEnabled() propery BuildType DSLオブジェクトでのみ使用できます。 multiDexEnabledProductFlavorオブジェクトを指します。したがって、これらのプロパティを結合する場合は、これらのオブジェクトの両方でプロパティを指定する必要があります。 prodRelease - 例えば:

productFlavors { 
    dev { 
     minSdkVersion 21 
     multiDexEnabled false 
    } 
    prod { 
     minSdkVersion 16 
     multiDexEnabled true 
    } 
} 

buildTypes { 
    debug { 
     minifyEnabled false 
    } 
    release { 
     minifyEnabled true 
    } 
} 

デバッグのためにはリリースのために、devDebugビルドバリアントを使用して構築します。

0

@maxost
によって示唆されるように、私が提供した直下のAndroid開発者が
が ここで[https://developer.android.com/studio/build/multidex.html#dev-build]参照してくださいリンク:

android { 
      defaultConfig { 
       ... 
       multiDexEnabled true 
      } 
      productFlavors { 
       dev { 
        // Enable pre-dexing to produce an APK that can be tested on 
        // Android 5.0+ without the time-consuming DEX build processes. 
        minSdkVersion 21 
       } 
       prod { 
        // The actual minSdkVersion for the production version. 
        minSdkVersion 14 
       } 
      } 
      buildTypes { 
       release { 
        minifyEnabled true 
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
                 'proguard-rules.pro' 
       } 
      } 
     } 
     dependencies { 
      compile 'com.android.support:multidex:1.0.1' 
     } 
関連する問題