The files of the java directory in Android productflavors multi-channel packaging are not merged?

my build.gradle configuration:

flavorDimensions "default"
productFlavors {

    free {
        dimension "default"
        applicationId "com.android.hello.free"
    }

    pro {
        dimension "default"
        applicationId "com.android.hello.pro"
    }
}


the situation goes like this:

  1. I finished clean the project, and then click run. App is running normally
  2. then I randomly change a line of code, and then click run, then there will be a problem, there will be a crash saying that the class can not be found.
  3. at this time, if I run after clean, I can run normally again

based on the above phenomenon, I looked at the files in the apk package and found that the java files were not merged. It is strange that according to the official documents and online materials, my integration should be no problem, the question is why the merger. I use the android studio version as 3.1.3 .

I hope someone can answer

Menu