具有风格和依赖性的Android库

时间:2018-04-17 08:09:25

标签: android android-library android-productflavors android-flavors

我有自定义图书馆的口味"水"和"蓝" :

   flavorDimensions "water", "blue"

   productFlavors 
   {
   water 
   {
    flavorDimensions "water"
   }
   blue
   {
    flavorDimensions "blue"
   }
   }
   configurations 
   {
   waterDebugCompile
   waterReleaseCompile

   blueDebugCompile
   blueReleaseCompile
   }

两者都覆盖来自" main"的TestA.class。文件夹

 TestA.class from "main" has a method that toast "MAIN"
 TestA.class from "water" => "WATER"
 TestA.class from "blue" => "BLUE"
在应用程序中

我有:

   dependencies {
   implementation project(':mylibrary')
   }

  flavorDimensions "water", "blue"

  productFlavors  {
     water {
        flavorDimensions "water"
        applicationId "com.test.water"
        matchingFallbacks = ['water']

     }
     blue {
        flavorDimensions "blue"
        applicationId "com.test.blue"
        matchingFallbacks = ['blue']
     }
  }

但是当我选择" blueDebug"变种可以应用它吐司" MAIN"而不是" BLUE"正如我所期待的那样

为什么?

由于

0 个答案:

没有答案