Gradle flavors for android with custom source sets - what should the gradle files look like?

后端 未结 5 1125
慢半拍i
慢半拍i 2020-12-02 10:19

I\'ve got an old eclipse project I\'ve moved into android studio and setup to use flavors. It seemed to be working fine till I started trying to use different java files be

5条回答
  •  隐瞒了意图╮
    2020-12-02 11:15

    Here is what my Gradle looks like :

       productFlavors {
        // Still keeping the productFlavors closure in case we decide to add flavors later
        normal {
            applicationId 'com.akshat'
        }
        qa {
            applicationId 'com.akshat.qa'
        }
    }
    
     sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jni.srcDirs = [] // Set empty since we use our own ndkBuild task
            jniLibs.srcDirs = ['libs']
        }
    
        normal {
            java.srcDirs = ['src_normal']
        }
        qa{
            java.srcDirs = ['src_qa']
        }
    

    And here is how my Directory structure is :

    MyApplication
        - res
        - libs
        - jni 
        - src
             -com/akshat/
        - src_qa
             - com/akshat/util/FlavorConst.java
        - src_normal
             - com/akshat/util/FlavorConst.java
    

提交回复
热议问题