Dates with fragrance and package names

I have two Flavorsin my application, so my project has this structure:

productFlavors {
            green {
                resValue "string", "app_name", "green"
                minSdkVersion 14
                applicationId 'com.company.green'
                targetSdkVersion 22
                versionCode 3
                versionName '3.0.3'
            }

            red {
                resValue "string", "app_name", "red"
                minSdkVersion 14
                applicationId 'com.company.red'
                targetSdkVersion 22
                versionCode 3
                versionName '3.0.3'
                 }
             }          

I also have a different implementation of the class in all Flavorand public classes in the main package.
Now let's say that I have to implement a class:

My class

This class will have a different implementation for each flavor, so I will implement the class inside green and red Flavor

After creating MyClasson green, FlavorI get this error in the class itself.

package name com.company.MyClass does not match file path

I also tried

package com.company.green.MyClass

But I get the same package name error

So my question is: What is the correct package name for each Flavor?

+4
1

MyClass.java : <project>/<module>/src/green/java/com/company/MyClass.java <project>/<module>/src/red/java/com/company/MyClass.java

package com.company,
applicationId, , .

import com.company.MyClass , MyClass.

file tree

. gist.

0

Source: https://habr.com/ru/post/1681178/


All Articles