在 Android Studio 中使用 Gradle 风格

Using the Gradle flavor in Android Studio

我想制作一个具有两个不同版本的 Android 应用程序。

这就是我想要实现的

Main Screen 调用 Class 中名为 Execute

的方法

现在我想要两个不同版本的Execute class。我们将第一个版本称为 Flavor1,将第二个版本称为 Flavor2Flavor1 需要一个名为 Test1 的库的帮助。而 Flavor2 执行 class 将需要名为 Test2.

的库的帮助

现在我想要实现的是,当我尝试构建 Flavor1 时,Test 2 库不应包含在 APK file 中。当我构建 Flavor2 时,Test1 库不应包含在 APK file.

这就是场景

Main Class --> Execute Class

Execute Class(Flavor1)-->Test1 Library

Execute Class(Flavor2)-->Test2 Library

Building Flavor1 should not contain Test2 Library

Building Flavor2 Should not contain Test1 Library

有什么办法可以做到这一点。任何帮助将不胜感激。

如果你已经适当地定义了风味,你可以有风味特定的实现如下:-

假设我根据口味有两个不同的应用程序兼容版本

flavorOneImplementation 'com.android.support:appcompat-v7:27.0.2'
flavorTwoImplementation 'com.android.support:appcompat-v7:24.2.0'