Conditional dependencies with Gradle, is it possible?

前端 未结 3 1250
醉话见心
醉话见心 2021-01-12 21:41

I have an Android project (already ported to Android Studio and using Gradle) that is made up of different modules.

The project is actually used to create two differ

3条回答
  •  难免孤独
    2021-01-12 21:50

    Since you already have the product flavors:

    productFlavors {
        producta {
        }
    
        productb {
        }
    }
    

    Define your dependencies prefixed with flavor name. Example:

    dependencies {
        productaImplementation 'com.google.android.gms:play-services:11.0.2'
        productbImplementation 'com.google.android.gms:play-services:12.0.1'
    }
    

    Common dependencies will be defined normally.

    Now build apk for individual flavors.

提交回复
热议问题