我有一个应用程序,它使用与付费和免费版本相同的代码库..
下面的缩减build.gradle
给出了结构的概念
android {
....
defaultConfig {
applicationId "com.myco.myapp"
....
}
buildTypes {
....
release {
....
}
}
productFlavors {
free {
applicationIdSuffix ".free"
buildConfigField "boolean", "PREMIUM", "false"
buildConfigField "boolean", "FREE", "true"
}
premium {
applicationIdSuffix ".premium"
buildConfigField "boolean", "PREMIUM", "true"
buildConfigField "boolean", "FREE", "false"
}
}
dependencies {
....
compile project(path: ':LVL')
}
我在onCreate
中调用LVL许可证如下: -
if (BuildConfig.PREMIUM) {
String deviceId = Settings.Secure.ANDROID_ID;
Log.i(TAG, "Device Id: " + deviceId);
mHandler = new Handler();
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
// Construct the LicenseChecker with a Policy.
mChecker = new LicenseChecker(
getApplicationContext(), new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY // Your public licensing key.
);
doCheck();
}
myapp
的“免费”版本未调用或要求LVL库。我的问题是: - 我应该如何构建我的项目/ build.gradle
,以便LVL库不包含在Free版本的APK中(但是包含在Premium版本中?