简体   繁体   English

在Android Studio中使用Gradle风格

[英]Using the Gradle flavor in Android Studio

I want to make an Android App with two different versions. 我想制作一个具有两个不同版本的Android应用。

This is what I want to achieve 这就是我要实现的

Main Screen calls a method in the Class named Execute Main Screen在名为Execute的类中调用一个方法

Now I want to have two different version of Execute class . 现在,我想拥有两个不同版本的Execute class Let's call the first one Flavor1 and the second version as Flavor2 . 让我们把第一个Flavor1和第二版本Flavor2 Flavor1 will need the help of a library called Test1 . Flavor1将需要一个名为Test1的库的帮助。 Whereas the Flavor2 Execute class will need the Help of library called Test2 . Flavor2 Execute类将需要名为Test2的库的帮助。

Now what I am trying to achieve is when I try to build the Flavor1 then Test 2 library should NOT be included in the APK file . 现在我要实现的是,当我尝试构建Flavor1Test 2库不应包含在APK file And when I build the Flavor2 then the Test1 library should NOT be included in APK file . 当我构建Flavor2 ,Test1库不应包含在APK file

So this is the Scenario 这就是场景

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

Is there any way to achieve this. 有什么办法可以做到这一点。 Any Help would be grateful. 任何帮助将不胜感激。

If you have defined flavors appropriately you can have flavor specific implementations as following :- 如果您已经适当定义了口味,则可以使用以下特定口味的实现:

say I have two different app-compat versions as per flavors 说我有两种不同的应用程序兼容版本

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM