1
我有一个使用的付费和免费版本相同的代码库的应用程序..如何在只包含我的应用的高级版本中包含库项目而不包含免费版本?
的删节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')
}
我打电话的LVL许可的结构的想法onCreate
如下: -
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();
}
的LVL库不叫或在myapp
的“免费”版本所需。我的问题是: - ?我应该怎么构建我的项目/ build.gradle
,使LVL库不包含在免费版本的APK(但包含在高级版
谢谢。这确实回答了我的具体问题。但是,我已经决定实施虚拟“LVL”类或将MainActivity重新安排为“免费”和“高级”以免从“免费”版本中删除对LVL的调用,这是不值得的,所以我会在LV中加入LVL因为开销相对较小。 – SimonH