Android Studio Issue with gradle flavors in library module -


i have project multiple library modules in it. want create unique flavors in 1 modules, i've encountered strange error i'm having trouble solving.

in module's gradle file have following:

android {     defaultconfig {         testapplicationid "com.mytestapplication"     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt'         }     }      productflavors {        flav1 {             buildconfigfield 'string', 'project', '"flav1"'         }         flav2{             buildconfigfield 'string', 'project', '"flav2"'         }     } } 

but keep getting error:

error:cannot add task ':myaccessormodule:jarrelease' task name exists.  

if build.gradle file written this:

android {     defaultconfig {         testapplicationid "com.mytestapplication"     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt'         }     }      productflavors {        flav1 {             buildconfigfield 'string', 'project', '"flav1"'         }     } } 

then show me flav1debug , flav1release options in build variant window.

i'm wondering why fails when trying use 2 or more flavors? have not defined flavors in of other modules. documentation i've seen makes pretty easy. i've tried adding these flavors module through project structure gui, i'm getting same results. how module have multiple flavors?

cheers.

usually product flavors used create multiple apk versions same code.

so should have unique applicationids each flavor.

try using

productflavors {        flav1 {             applicationid "com.mytestapplication.flav1"         }         flav2{             applicationid "com.mytestapplication.flav2"         }     } 

for more info, https://developer.android.com/studio/build/build-variants.html


Comments